Push testig for UTP enabled further down.
authorJuliusz Chroboczek <jch@pps.univ-paris-diderot.fr>
Fri, 18 Feb 2011 00:35:56 +0000 (00:35 +0000)
committerJuliusz Chroboczek <jch@pps.univ-paris-diderot.fr>
Fri, 18 Feb 2011 00:35:56 +0000 (00:35 +0000)
There's no need to test for DHT/uTP being enabled in tr-udp.  The DHT
will silently discard any packets directed at the wrong session (see the
beginning of dhtCallback).  As to uTP, we need to grok uTP packets
to close any remaining connections after we disabled uTP, so it's better
to participate in uTP, just reject any incoming connections.

libtransmission/tr-udp.c
libtransmission/tr-utp.c

index 5f896c48fdcd8fd83330e11cad6680a97bfbfc36..85d962650122744969756bb6cef84e40812f3ccd 100644 (file)
@@ -135,11 +135,11 @@ event_callback(int s, short type UNUSED, void *sv)
     if(rc <= 0)
         return;
 
-    if((buf[0] == 'd') && tr_sessionIsDHTEnabled(ss)) {
+    if( buf[0] == 'd' ) {
         /* DHT packet. */
         buf[rc] = '\0';
         tr_dhtCallback(buf, rc, (struct sockaddr*)&from, fromlen, sv);
-    } else if(tr_sessionIsUTPEnabled(ss)){
+    } else {
         rc = tr_utpPacket(buf, rc, (struct sockaddr*)&from, fromlen, ss);
         if(!rc)
             tr_ndbg("UDP", "Unexpected UDP packet");
index 83aa51cacf06f8094a000a2f830fe6693acd6739..5c506b3d9275c967f07cae18ce80c32525eb6e36 100644 (file)
@@ -49,6 +49,11 @@ incoming(void *closure, struct UTPSocket *s)
     socklen_t fromlen = sizeof(from_storage);
     tr_address addr;
     tr_port port;
+
+    if( !tr_sessionIsUTPEnabled(ss) ) {
+        UTP_Close(s);
+        return;
+    }
     
     UTP_GetPeerName(s, from, &fromlen);
     if(from->sa_family == AF_INET) {