diff options
Diffstat (limited to 'ot_http.c')
-rw-r--r-- | ot_http.c | 14 |
1 files changed, 9 insertions, 5 deletions
@@ -385,7 +385,6 @@ static ssize_t http_handle_announce( const int64 client_socket, char *data ) { | |||
385 | char *c = data; | 385 | char *c = data; |
386 | int numwant, tmp, scanon; | 386 | int numwant, tmp, scanon; |
387 | ot_peer peer; | 387 | ot_peer peer; |
388 | ot_torrent *torrent; | ||
389 | ot_hash *hash = NULL; | 388 | ot_hash *hash = NULL; |
390 | unsigned short port = htons(6881); | 389 | unsigned short port = htons(6881); |
391 | ssize_t len; | 390 | ssize_t len; |
@@ -403,6 +402,10 @@ static ssize_t http_handle_announce( const int64 client_socket, char *data ) { | |||
403 | numwant = 50; | 402 | numwant = 50; |
404 | scanon = 1; | 403 | scanon = 1; |
405 | 404 | ||
405 | #ifdef _DEBUG_PEERID | ||
406 | g_this_peerid_data = NULL; | ||
407 | #endif | ||
408 | |||
406 | while( scanon ) { | 409 | while( scanon ) { |
407 | switch( scan_urlencoded_query( &c, data = c, SCAN_SEARCHPATH_PARAM ) ) { | 410 | switch( scan_urlencoded_query( &c, data = c, SCAN_SEARCHPATH_PARAM ) ) { |
408 | case -2: scanon = 0; break; /* TERMINATOR */ | 411 | case -2: scanon = 0; break; /* TERMINATOR */ |
@@ -483,10 +486,11 @@ static ssize_t http_handle_announce( const int64 client_socket, char *data ) { | |||
483 | 486 | ||
484 | if( OT_PEERFLAG( &peer ) & PEER_FLAG_STOPPED ) | 487 | if( OT_PEERFLAG( &peer ) & PEER_FLAG_STOPPED ) |
485 | len = remove_peer_from_torrent( hash, &peer, SUCCESS_HTTP_HEADER_LENGTH + static_outbuf, FLAG_TCP ); | 488 | len = remove_peer_from_torrent( hash, &peer, SUCCESS_HTTP_HEADER_LENGTH + static_outbuf, FLAG_TCP ); |
486 | else { | 489 | else |
487 | torrent = add_peer_to_torrent( hash, &peer WANT_SYNC_PARAM( 0 ) ); | 490 | len = add_peer_to_torrent_and_return_peers(hash, &peer, FLAG_TCP, numwant, SUCCESS_HTTP_HEADER_LENGTH + static_outbuf); |
488 | if( !torrent || !( len = return_peers_for_torrent( torrent, numwant, SUCCESS_HTTP_HEADER_LENGTH + static_outbuf, FLAG_TCP ) ) ) HTTPERROR_500; | 491 | |
489 | } | 492 | if( !len ) HTTPERROR_500; |
493 | |||
490 | stats_issue_event( EVENT_ANNOUNCE, FLAG_TCP, len); | 494 | stats_issue_event( EVENT_ANNOUNCE, FLAG_TCP, len); |
491 | return len; | 495 | return len; |
492 | } | 496 | } |