summaryrefslogtreecommitdiff
path: root/opentracker.c
diff options
context:
space:
mode:
Diffstat (limited to 'opentracker.c')
-rw-r--r--opentracker.c34
1 files changed, 9 insertions, 25 deletions
diff --git a/opentracker.c b/opentracker.c
index ccb9603..013441a 100644
--- a/opentracker.c
+++ b/opentracker.c
@@ -76,6 +76,9 @@ static size_t ot_sockets_count = 0;
76 76
77#ifdef _DEBUG_HTTPERROR 77#ifdef _DEBUG_HTTPERROR
78static char debug_request[8192]; 78static char debug_request[8192];
79#define _DEBUG_HTTPERROR_PARAM( param ) , param
80#else
81#define _DEBUG_HTTPERROR_PARAM( param )
79#endif 82#endif
80 83
81typedef enum { 84typedef enum {
@@ -99,12 +102,7 @@ static int ot_ip_compare( const void *a, const void *b ) { return memcmp( a,b,4
99int main( int argc, char **argv ); 102int main( int argc, char **argv );
100 103
101static void httperror( const int64 s, const char *title, const char *message ); 104static void httperror( const int64 s, const char *title, const char *message );
102 105static void httpresponse( const int64 s, char *data _DEBUG_HTTPERROR_PARAM(size_t l ) );
103#ifdef _DEBUG_HTTPERROR
104static void httpresponse( const int64 s, char *data, size_t l );
105#else
106static void httpresponse( const int64 s, char *data );
107#endif
108 106
109static void sendmmapdata( const int64 s, char *buffer, const size_t size ); 107static void sendmmapdata( const int64 s, char *buffer, const size_t size );
110static void senddata( const int64 s, char *buffer, const size_t size ); 108static void senddata( const int64 s, char *buffer, const size_t size );
@@ -226,11 +224,7 @@ static void senddata( const int64 s, char *buffer, size_t size ) {
226 } 224 }
227} 225}
228 226
229#ifdef _DEBUG_HTTPERROR 227static void httpresponse( const int64 s, char *data _DEBUG_HTTPERROR_PARAM( size_t l ) ) {
230static void httpresponse( const int64 s, char *data, size_t l ) {
231#else
232static void httpresponse( const int64 s, char *data ) {
233#endif
234 struct http_data* h = io_getcookie( s ); 228 struct http_data* h = io_getcookie( s );
235 char *c, *reply; 229 char *c, *reply;
236 ot_peer peer; 230 ot_peer peer;
@@ -675,13 +669,8 @@ static void handle_read( const int64 clientsocket ) {
675 669
676 /* If we get the whole request in one packet, handle it without copying */ 670 /* If we get the whole request in one packet, handle it without copying */
677 if( !array_start( &h->request ) ) { 671 if( !array_start( &h->request ) ) {
678 if( memchr( static_inbuf, '\n', l ) ) { 672 if( memchr( static_inbuf, '\n', l ) )
679 return httpresponse( clientsocket, static_inbuf 673 return httpresponse( clientsocket, static_inbuf _DEBUG_HTTPERROR_PARAM( l ) );
680#ifdef _DEBUG_HTTPERROR
681 , l
682#endif
683 );
684 }
685 h->flag |= STRUCT_HTTP_FLAG_ARRAY_USED; 674 h->flag |= STRUCT_HTTP_FLAG_ARRAY_USED;
686 return array_catb( &h->request, static_inbuf, l ); 675 return array_catb( &h->request, static_inbuf, l );
687 } 676 }
@@ -695,13 +684,8 @@ static void handle_read( const int64 clientsocket ) {
695 if( ( array_bytes( &h->request ) > 8192 ) && NOTBLESSED( h ) ) 684 if( ( array_bytes( &h->request ) > 8192 ) && NOTBLESSED( h ) )
696 return httperror( clientsocket, "500 request too long", "You sent too much headers"); 685 return httperror( clientsocket, "500 request too long", "You sent too much headers");
697 686
698 if( memchr( array_start( &h->request ), '\n', array_bytes( &h->request ) ) ) { 687 if( memchr( array_start( &h->request ), '\n', array_bytes( &h->request ) ) )
699 return httpresponse( clientsocket, array_start( &h->request ) 688 return httpresponse( clientsocket, array_start( &h->request ) _DEBUG_HTTPERROR_PARAM( array_bytes( &h->request ) ) );
700#ifdef _DEBUG_HTTPERROR
701 , array_bytes( &h->request )
702#endif
703 );
704 }
705} 689}
706 690
707static void handle_write( const int64 clientsocket ) { 691static void handle_write( const int64 clientsocket ) {