diff options
author | erdgeist <> | 2007-10-29 17:22:05 +0000 |
---|---|---|
committer | erdgeist <> | 2007-10-29 17:22:05 +0000 |
commit | 31eada6168f9c2433b0b7cd3ef21861f76d21784 (patch) | |
tree | 884b0ed46a45a163b389ccbd4823b910eaf6ef5e /opentracker.c | |
parent | b19bbd6a850ecd51180dfea6e025a032fb2f1fe1 (diff) |
Reenabled syncing
Diffstat (limited to 'opentracker.c')
-rw-r--r-- | opentracker.c | 31 |
1 files changed, 27 insertions, 4 deletions
diff --git a/opentracker.c b/opentracker.c index d9336da..bf9db89 100644 --- a/opentracker.c +++ b/opentracker.c | |||
@@ -49,6 +49,10 @@ static char *accesslist_filename = NULL; | |||
49 | #define WANT_ACCESS_CONTROL | 49 | #define WANT_ACCESS_CONTROL |
50 | #endif | 50 | #endif |
51 | 51 | ||
52 | #ifndef WANT_TRACKER_SYNC | ||
53 | #define add_peer_to_torrent(A,B,C) add_peer_to_torrent(A,B) | ||
54 | #endif | ||
55 | |||
52 | #ifndef NO_FULLSCRAPE_LOGGING | 56 | #ifndef NO_FULLSCRAPE_LOGGING |
53 | #define LOG_TO_STDERR( ... ) fprintf( stderr, __VA_ARGS__ ) | 57 | #define LOG_TO_STDERR( ... ) fprintf( stderr, __VA_ARGS__ ) |
54 | #else | 58 | #else |
@@ -91,7 +95,12 @@ struct http_data { | |||
91 | int main( int argc, char **argv ); | 95 | int main( int argc, char **argv ); |
92 | 96 | ||
93 | static void httperror( const int64 s, const char *title, const char *message ); | 97 | static void httperror( const int64 s, const char *title, const char *message ); |
98 | |||
99 | #ifdef _DEBUG_HTTPERROR | ||
94 | static void httpresponse( const int64 s, char *data, size_t l ); | 100 | static void httpresponse( const int64 s, char *data, size_t l ); |
101 | #else | ||
102 | static void httpresponse( const int64 s, char *data ); | ||
103 | #endif | ||
95 | 104 | ||
96 | static void sendmmapdata( const int64 s, char *buffer, const size_t size ); | 105 | static void sendmmapdata( const int64 s, char *buffer, const size_t size ); |
97 | static void senddata( const int64 s, char *buffer, const size_t size ); | 106 | static void senddata( const int64 s, char *buffer, const size_t size ); |
@@ -213,7 +222,11 @@ static void senddata( const int64 s, char *buffer, size_t size ) { | |||
213 | } | 222 | } |
214 | } | 223 | } |
215 | 224 | ||
225 | #ifdef _DEBUG_HTTPERROR | ||
216 | static void httpresponse( const int64 s, char *data, size_t l ) { | 226 | static void httpresponse( const int64 s, char *data, size_t l ) { |
227 | #else | ||
228 | static void httpresponse( const int64 s, char *data ) { | ||
229 | #endif | ||
217 | struct http_data* h = io_getcookie( s ); | 230 | struct http_data* h = io_getcookie( s ); |
218 | char *c, *reply; | 231 | char *c, *reply; |
219 | ot_peer peer; | 232 | ot_peer peer; |
@@ -643,8 +656,13 @@ static void handle_read( const int64 clientsocket ) { | |||
643 | 656 | ||
644 | /* If we get the whole request in one packet, handle it without copying */ | 657 | /* If we get the whole request in one packet, handle it without copying */ |
645 | if( !array_start( &h->request ) ) { | 658 | if( !array_start( &h->request ) ) { |
646 | if( memchr( static_inbuf, '\n', l ) ) | 659 | if( memchr( static_inbuf, '\n', l ) ) { |
647 | return httpresponse( clientsocket, static_inbuf, l ); | 660 | return httpresponse( clientsocket, static_inbuf |
661 | #ifdef _DEBUG_HTTPERROR | ||
662 | , l | ||
663 | #endif | ||
664 | ); | ||
665 | } | ||
648 | h->flag |= STRUCT_HTTP_FLAG_ARRAY_USED; | 666 | h->flag |= STRUCT_HTTP_FLAG_ARRAY_USED; |
649 | return array_catb( &h->request, static_inbuf, l ); | 667 | return array_catb( &h->request, static_inbuf, l ); |
650 | } | 668 | } |
@@ -658,8 +676,13 @@ static void handle_read( const int64 clientsocket ) { | |||
658 | if( ( array_bytes( &h->request ) > 8192 ) && NOTBLESSED( h ) ) | 676 | if( ( array_bytes( &h->request ) > 8192 ) && NOTBLESSED( h ) ) |
659 | return httperror( clientsocket, "500 request too long", "You sent too much headers"); | 677 | return httperror( clientsocket, "500 request too long", "You sent too much headers"); |
660 | 678 | ||
661 | if( memchr( array_start( &h->request ), '\n', array_bytes( &h->request ) ) ) | 679 | if( memchr( array_start( &h->request ), '\n', array_bytes( &h->request ) ) ) { |
662 | return httpresponse( clientsocket, array_start( &h->request ), array_bytes( &h->request ) ); | 680 | return httpresponse( clientsocket, array_start( &h->request ) |
681 | #ifdef _DEBUG_HTTPERROR | ||
682 | , array_bytes( &h->request ) | ||
683 | #endif | ||
684 | ); | ||
685 | } | ||
663 | } | 686 | } |
664 | 687 | ||
665 | static void handle_write( const int64 clientsocket ) { | 688 | static void handle_write( const int64 clientsocket ) { |