1
0
Fork 0
mirror of https://github.com/transmission/transmission synced 2024-12-25 17:17:31 +00:00

(trunk libT) #4351 "DHT can't be uninitialized during a session" -- don't process incoming DHT messages if DHT is disabled. Don't process incoming UTP messages if UTP is disabled.

This commit is contained in:
Jordan Lee 2011-07-12 12:26:24 +00:00
parent 731ee3640c
commit 7b71470ea0
2 changed files with 15 additions and 7 deletions

View file

@ -345,8 +345,10 @@ tr_dhtUninit(tr_session *ss)
tr_ndbg( "DHT", "Uninitializing DHT" ); tr_ndbg( "DHT", "Uninitializing DHT" );
event_free( dht_timer ); if( dht_timer != NULL ) {
dht_timer = NULL; event_free( dht_timer );
dht_timer = NULL;
}
/* Since we only save known good nodes, avoid erasing older data if we /* Since we only save known good nodes, avoid erasing older data if we
don't know enough nodes. */ don't know enough nodes. */

View file

@ -209,17 +209,21 @@ event_callback(int s, short type UNUSED, void *sv)
version number (1). */ version number (1). */
if(rc > 0) { if(rc > 0) {
if( buf[0] == 'd' ) { if( buf[0] == 'd' ) {
buf[rc] = '\0'; /* required by the DHT code */ if( tr_sessionAllowsDHT( ss ) ) {
tr_dhtCallback(buf, rc, (struct sockaddr*)&from, fromlen, sv); buf[rc] = '\0'; /* required by the DHT code */
tr_dhtCallback(buf, rc, (struct sockaddr*)&from, fromlen, sv);
}
} else if( rc >= 8 && } else if( rc >= 8 &&
buf[0] == 0 && buf[1] == 0 && buf[2] == 0 && buf[3] <= 3 ) { buf[0] == 0 && buf[1] == 0 && buf[2] == 0 && buf[3] <= 3 ) {
rc = tau_handle_message( ss, buf, rc ); rc = tau_handle_message( ss, buf, rc );
if( !rc ) if( !rc )
tr_ndbg("UDP", "Couldn't parse UDP tracker packet."); tr_ndbg("UDP", "Couldn't parse UDP tracker packet.");
} else { } else {
rc = tr_utpPacket(buf, rc, (struct sockaddr*)&from, fromlen, ss); if( tr_sessionIsUTPEnabled( ss ) ) {
if( !rc ) rc = tr_utpPacket(buf, rc, (struct sockaddr*)&from, fromlen, ss);
tr_ndbg("UDP", "Unexpected UDP packet"); if( !rc )
tr_ndbg("UDP", "Unexpected UDP packet");
}
} }
} }
} }
@ -289,6 +293,8 @@ tr_udpInit(tr_session *ss)
void void
tr_udpUninit(tr_session *ss) tr_udpUninit(tr_session *ss)
{ {
tr_dhtUninit(ss);
if(ss->udp_socket >= 0) { if(ss->udp_socket >= 0) {
tr_netCloseSocket( ss->udp_socket ); tr_netCloseSocket( ss->udp_socket );
ss->udp_socket = -1; ss->udp_socket = -1;