From 46605bcb2c08afcad8a887cac1b70b848915d87a Mon Sep 17 00:00:00 2001 From: denis <> Date: Fri, 16 Mar 2007 23:04:24 +0000 Subject: [PATCH] some udp scrape style cleanup --- opentracker.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/opentracker.c b/opentracker.c index 2fb6bf5..9e0a18c 100644 --- a/opentracker.c +++ b/opentracker.c @@ -628,31 +628,31 @@ static void handle_udp4( int64 serversocket ) { case 3: OT_FLAG( &peer ) |= PEER_FLAG_STOPPED; break; default: break; } + if( !left ) OT_FLAG( &peer ) |= PEER_FLAG_SEEDING; + outpacket[0] = htonl( 1 ); /* announce action */ + outpacket[1] = inpacket[12/4]; + if( OT_FLAG( &peer ) & PEER_FLAG_STOPPED ) { /* Peer is gone. */ remove_peer_from_torrent( hash, &peer ); /* Create fake packet to satisfy parser on the other end */ - outpacket[0] = htonl( 1 ); - outpacket[1] = inpacket[12/4]; outpacket[2] = htonl( OT_CLIENT_REQUEST_INTERVAL_RANDOM ); outpacket[3] = outpacket[4] = 0; - socket_send4( serversocket, static_outbuf, 20, remoteip, remoteport ); - ot_overall_udp_successfulannounces++; + r = 20; } else { torrent = add_peer_to_torrent( hash, &peer ); if( !torrent ) return; /* XXX maybe send error */ - outpacket[0] = htonl( 1 ); /* announce action */ - outpacket[1] = inpacket[12/4]; r = 8 + return_peers_for_torrent( torrent, numwant, static_outbuf + 8, 0 ); - socket_send4( serversocket, static_outbuf, r, remoteip, remoteport ); - ot_overall_udp_successfulannounces++; } + + socket_send4( serversocket, static_outbuf, r, remoteip, remoteport ); + ot_overall_udp_successfulannounces++; break; case 2: /* This is a scrape action */