From 33c9c530d00f6993118ee23cc4cde1b16c7ad978 Mon Sep 17 00:00:00 2001 From: erdgeist <> Date: Mon, 10 Sep 2007 02:43:11 +0000 Subject: An announce with event=stopped now returns correct number of leechers and seeders. In TCP and UDP. --- opentracker.c | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) (limited to 'opentracker.c') diff --git a/opentracker.c b/opentracker.c index 4ffde37..646184c 100644 --- a/opentracker.c +++ b/opentracker.c @@ -441,10 +441,9 @@ ANNOUNCE_WORKAROUND: reply_size = sprintf( static_outbuf + SUCCESS_HTTP_HEADER_LENGTH, "d14:failure reason81:Your client forgot to send your torrent's info_hash. Please upgrade your client.e" ); break; } - if( OT_FLAG( &peer ) & PEER_FLAG_STOPPED ) { - remove_peer_from_torrent( hash, &peer ); - reply_size = sprintf( static_outbuf + SUCCESS_HTTP_HEADER_LENGTH, "d8:completei0e10:incompletei0e8:intervali%ie5:peers0:e", OT_CLIENT_REQUEST_INTERVAL_RANDOM ); - } else { + if( OT_FLAG( &peer ) & PEER_FLAG_STOPPED ) + reply_size = remove_peer_from_torrent( hash, &peer, SUCCESS_HTTP_HEADER_LENGTH + static_outbuf, 1 ); + else { torrent = add_peer_to_torrent( hash, &peer, 0 ); if( !torrent || !( reply_size = return_peers_for_torrent( torrent, numwant, SUCCESS_HTTP_HEADER_LENGTH + static_outbuf, 1 ) ) ) HTTPERROR_500; } @@ -680,15 +679,9 @@ static void handle_udp4( int64 serversocket ) { 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[2] = htonl( OT_CLIENT_REQUEST_INTERVAL_RANDOM ); - outpacket[3] = outpacket[4] = 0; - r = 20; - } else { + if( OT_FLAG( &peer ) & PEER_FLAG_STOPPED ) /* Peer is gone. */ + r = remove_peer_from_torrent( hash, &peer, static_outbuf, 0 ); + else { torrent = add_peer_to_torrent( hash, &peer, 0 ); if( !torrent ) return; /* XXX maybe send error */ -- cgit v1.2.3