Changeset 52


Ignore:
Timestamp:
Jan 25, 2006, 5:20:21 PM (16 years ago)
Author:
joshe
Message:

Send stopped and started events to trackers when the listening port is changed,
but without disrupting existing peer connections.
In the GTK prefs dialog, change the port immediately instead of on next invocation.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/gtk/prefs.c

    r51 r52  
    180180    cf_setpref(PREF_PORT, strnum);
    181181    g_free(strnum);
    182     /* XXX should I change the port here?  is it even possible? */
    183182
    184183    /* save uselimit pref */
     
    198197    }
    199198
     199    tr_setBindPort(data->tr, gtk_spin_button_get_value_as_int(data->port));
    200200    setlimit(data->tr);
    201201  }
  • trunk/libtransmission/tracker.c

    r26 r52  
    5252
    5353    int            bindPort;
     54    int            newPort;
    5455};
    5556
     
    7576
    7677    tc->bindPort = h->bindPort;
     78    tc->newPort  = -1;
    7779
    7880    return tc;
     
    9092
    9193    /* Do we need to send an event? */
    92     if( tc->started || tc->completed || tc->stopped )
     94    if( tc->started || tc->completed || tc->stopped || 0 < tc->newPort )
    9395    {
    9496        return 1;
     
    124126void tr_trackerChangePort( tr_tracker_t * tc, int port )
    125127{
    126     /* XXX this doesn't always work, should send stopped then started events */
    127     tc->bindPort = port;
     128    tc->newPort = port;
    128129}
    129130
     
    161162                ( tc->completed ? "sending 'completed'" :
    162163                  ( tc->stopped ? "sending 'stopped'" :
    163                     "getting peers" ) ) );
     164                    ( 0 < tc->newPort ? "sending 'stopped' to change port" :
     165                      "getting peers" ) ) ) );
    164166
    165167        tc->status  = TC_STATUS_CONNECT;
     
    247249    int        ret;
    248250
     251    if( tc->started && 0 < tc->newPort )
     252    {
     253        tc->bindPort = tc->newPort;
     254        tc->newPort = -1;
     255    }
     256
    249257    if( tc->started )
    250258        event = "&event=started";
    251259    else if( tc->completed )
    252260        event = "&event=completed";
    253     else if( tc->stopped )
     261    else if( tc->stopped || 0 < tc->newPort )
    254262        event = "&event=stopped";
    255263    else
     
    480488        tc->stopped = 0;
    481489    }
     490    else if( 0 < tc->newPort )
     491    {
     492        tc->started = 1;
     493    }
    482494
    483495cleanup:
Note: See TracChangeset for help on using the changeset viewer.