Changeset 3119


Ignore:
Timestamp:
Sep 21, 2007, 5:31:29 AM (15 years ago)
Author:
charles
Message:

slightly less broken handling of cases where we can't bind to our listening port.

Location:
trunk/libtransmission
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/libtransmission/internal.h

    r3105 r3119  
    6161void tr_torrentUnlock  ( const tr_torrent * );
    6262
    63 void tr_torrentChangeMyPort  ( tr_torrent *, int port );
     63void tr_torrentChangeMyPort  ( tr_torrent * );
    6464
    6565int tr_torrentExists( tr_handle *, const uint8_t * );
     
    121121
    122122    uint8_t                  * azId;
    123     int                        publicPort;
    124123
    125124    /* Where to download */
  • trunk/libtransmission/shared.c

    r3105 r3119  
    146146
    147147    /* Create the new one */
     148    s->bindSocket = tr_netBindTCP( port );
     149
     150    /* Notify the trackers */
     151    SetPublicPort( s, port );
     152
    148153    /* XXX should handle failure here in a better way */
    149     s->bindSocket = tr_netBindTCP( port );
    150     if( 0 > s->bindSocket )
    151     {
    152         /* Notify the trackers */
    153         SetPublicPort( s, 0 );
     154    if( s->bindSocket < 0 )
     155    {
    154156        /* Remove the forwarding for the old port */
    155157        tr_natpmpRemoveForwarding( s->natpmp );
     
    160162        tr_inf( "Bound listening port %d", port );
    161163        listen( s->bindSocket, 5 );
    162         if( port != s->publicPort )
    163         {
    164             /* Notify the trackers */
    165             SetPublicPort( s, port );
    166         }
    167164        /* Forward the new port */
    168165        tr_natpmpForwardPort( s->natpmp, port );
     
    175172int tr_sharedGetPublicPort( tr_shared * s )
    176173{
     174fprintf( stderr, "%s:%d tr_sharedGetPublicPort returning %d\n", __FILE__, __LINE__, (int)s->publicPort );
    177175    return s->publicPort;
    178176}
     
    269267
    270268    for( tor = h->torrentList; tor; tor = tor->next )
    271         tr_torrentChangeMyPort( tor, port );
     269        tr_torrentChangeMyPort( tor );
    272270}
    273271
  • trunk/libtransmission/torrent.c

    r3111 r3119  
    360360                                  NULL );
    361361 
    362     /* We have a new torrent */
    363     tor->publicPort = tr_sharedGetPublicPort( h->shared );
    364 
    365362    tr_sharedUnlock( h->shared );
    366363
     
    668665
    669666void
    670 tr_torrentChangeMyPort( tr_torrent * tor, int port )
    671 {
    672     tr_torrentLock( tor );
    673 
    674     tor->publicPort = port;
    675 
     667tr_torrentChangeMyPort( tr_torrent * tor )
     668{
    676669    if( tor->tracker )
    677670        tr_trackerChangeMyPort( tor->tracker );
    678 
    679     tr_torrentUnlock( tor );
    680671}
    681672
  • trunk/libtransmission/tracker.c

    r3117 r3119  
    2929#include "ptrarray.h"
    3030#include "publish.h"
     31#include "shared.h"
    3132#include "tracker.h"
    3233#include "trevent.h"
     
    772773        tor->escaped,
    773774        tor->peer_id,
    774         torrent->publicPort,
     775        tr_sharedGetPublicPort( torrent->handle->shared ),
    775776        torrent->uploadedCur,
    776777        torrent->downloadedCur,
Note: See TracChangeset for help on using the changeset viewer.