diff options
| author | erdgeist <> | 2009-01-02 08:57:53 +0000 |
|---|---|---|
| committer | erdgeist <> | 2009-01-02 08:57:53 +0000 |
| commit | 2df09905f5540fee096d48a92cb0c42558498a12 (patch) | |
| tree | 68eab61d29719400972485de395dd0465467aea6 /ot_http.c | |
| parent | 548e2b8338b5ee8d24fa928e833f345bb5cb6f0e (diff) | |
* opentracker now drops permissions in correct order and really chroots() if ran as root
* lock passing between add_peer_to_torrent and return_peers_for_torrent is now avoided by providing a more general add_peer_to_torrent_and_return_peers function that can be used with NULL parameters to not return any peers (in sync case)
* in order to keep a fast overview how many torrents opentracker maintains, every mutex_bucket_unlock operation expects an additional integer parameter that tells ot_mutex.c how many torrents have been added or removed. A function mutex_get_torrent_count has been introduced.
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 | } |
