Ticket #1398: paused-handshake.diff
File paused-handshake.diff, 3.3 KB (added by charles, 12 years ago) |
---|
-
libtransmission/port-forwarding.c
struct tr_shared 42 42 int bindSocket; 43 43 int publicPort; 44 44 45 tr_ handle * h;45 tr_session * session; 46 46 tr_timer * pulseTimer; 47 47 48 48 tr_upnp * upnp; … … natPulse( tr_shared * s ) 103 103 static void 104 104 incomingPeersPulse( tr_shared * s ) 105 105 { 106 int allPaused; 107 tr_torrent * tor; 108 106 109 if( s->bindSocket >= 0 && ( s->bindPort != s->publicPort ) ) 107 110 { 108 111 tr_ninf( getKey( ), _( "Closing port %d" ), s->bindPort ); … … incomingPeersPulse( tr_shared * s ) 136 139 } 137 140 } 138 141 139 for( ; ; ) /* check for new incoming peer connections */ 142 /* see if any torrents aren't paused */ 143 allPaused = 1; 144 tor = NULL; 145 while(( tor = tr_torrentNext( s->session, tor ))) { 146 if( TR_STATUS_IS_ACTIVE( tr_torrentGetActivity( tor ))) { 147 allPaused = 0; 148 break; 149 } 150 } 151 152 /* if we have any running torrents, check for new incoming peer connections */ 153 while( !allPaused ) 140 154 { 141 int 142 uint16_t 155 int socket; 156 uint16_t port; 143 157 struct in_addr addr; 144 158 145 159 if( s->bindSocket < 0 ) … … incomingPeersPulse( tr_shared * s ) 151 165 152 166 tr_deepLog( __FILE__, __LINE__, NULL, 153 167 "New INCOMING connection %d (%s)", 154 socket, tr_peerIoAddrStr( &addr, 155 port ) ); 168 socket, tr_peerIoAddrStr( &addr, port ) ); 156 169 157 tr_peerMgrAddIncoming( s-> h->peerMgr, &addr, port, socket );170 tr_peerMgrAddIncoming( s->session->peerMgr, &addr, port, socket ); 158 171 } 159 172 } 160 173 … … sharedPulse( void * vshared ) 177 190 tr_netClose( shared->bindSocket ); 178 191 tr_natpmpClose( shared->natpmp ); 179 192 tr_upnpClose( shared->upnp ); 180 shared-> h->shared = NULL;193 shared->session->shared = NULL; 181 194 tr_free( shared ); 182 195 keepPulsing = 0; 183 196 } … … sharedPulse( void * vshared ) 190 203 ***/ 191 204 192 205 tr_shared * 193 tr_sharedInit( tr_ handle * h,194 int isEnabled,195 int publicPort )206 tr_sharedInit( tr_session * session, 207 int isEnabled, 208 int publicPort ) 196 209 { 197 210 tr_shared * s = tr_new0( tr_shared, 1 ); 198 211 199 s-> h = h;212 s->session = session; 200 213 s->publicPort = publicPort; 201 214 s->bindPort = -1; 202 215 s->bindSocket = -1; 203 216 s->natpmp = tr_natpmpInit( ); 204 217 s->upnp = tr_upnpInit( ); 205 s->pulseTimer = tr_timerNew( h, sharedPulse, s, 1000 );218 s->pulseTimer = tr_timerNew( session, sharedPulse, s, 1000 ); 206 219 s->isEnabled = isEnabled ? 1 : 0; 207 220 s->upnpStatus = TR_PORT_UNMAPPED; 208 221 s->natpmpStatus = TR_PORT_UNMAPPED; … … tr_sharedSetPort( tr_shared * s, 224 237 225 238 s->publicPort = port; 226 239 227 while( ( tor = tr_torrentNext( s-> h, tor ) ) )240 while( ( tor = tr_torrentNext( s->session, tor ) ) ) 228 241 tr_torrentChangeMyPort( tor ); 229 242 } 230 243