summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorerdgeist <>2009-01-03 03:25:37 +0000
committererdgeist <>2009-01-03 03:25:37 +0000
commit8bdc0d73f6f0bcaf83b7fb3d39e79e8fa4e6050d (patch)
treea75f8eed836bbea20992f92093160cd345c29f60
parent2df09905f5540fee096d48a92cb0c42558498a12 (diff)
Make opentracker ANSI C again.
-rw-r--r--opentracker.c20
-rw-r--r--ot_http.c14
-rw-r--r--ot_http.h2
-rw-r--r--ot_mutex.c2
-rw-r--r--ot_stats.c1
5 files changed, 19 insertions, 20 deletions
diff --git a/opentracker.c b/opentracker.c
index 993877a..bce5be0 100644
--- a/opentracker.c
+++ b/opentracker.c
@@ -97,9 +97,9 @@ static void handle_dead( const int64 socket ) {
97 struct http_data* h=io_getcookie( socket ); 97 struct http_data* h=io_getcookie( socket );
98 if( h ) { 98 if( h ) {
99 if( h->flag & STRUCT_HTTP_FLAG_IOB_USED ) 99 if( h->flag & STRUCT_HTTP_FLAG_IOB_USED )
100 iob_reset( &h->batch ); 100 iob_reset( &h->data.batch );
101 if( h->flag & STRUCT_HTTP_FLAG_ARRAY_USED ) 101 if( h->flag & STRUCT_HTTP_FLAG_ARRAY_USED )
102 array_reset( &h->request ); 102 array_reset( &h->data.request );
103 if( h->flag & STRUCT_HTTP_FLAG_WAITINGFORTASK ) 103 if( h->flag & STRUCT_HTTP_FLAG_WAITINGFORTASK )
104 mutex_workqueue_canceltask( socket ); 104 mutex_workqueue_canceltask( socket );
105 free( h ); 105 free( h );
@@ -117,32 +117,32 @@ static ssize_t handle_read( const int64 clientsocket ) {
117 } 117 }
118 118
119 /* If we get the whole request in one packet, handle it without copying */ 119 /* If we get the whole request in one packet, handle it without copying */
120 if( !array_start( &h->request ) ) { 120 if( !array_start( &h->data.request ) ) {
121 if( memchr( static_inbuf, '\n', l ) ) 121 if( memchr( static_inbuf, '\n', l ) )
122 return http_handle_request( clientsocket, static_inbuf, l ); 122 return http_handle_request( clientsocket, static_inbuf, l );
123 h->flag |= STRUCT_HTTP_FLAG_ARRAY_USED; 123 h->flag |= STRUCT_HTTP_FLAG_ARRAY_USED;
124 array_catb( &h->request, static_inbuf, l ); 124 array_catb( &h->data.request, static_inbuf, l );
125 return 0; 125 return 0;
126 } 126 }
127 127
128 h->flag |= STRUCT_HTTP_FLAG_ARRAY_USED; 128 h->flag |= STRUCT_HTTP_FLAG_ARRAY_USED;
129 array_catb( &h->request, static_inbuf, l ); 129 array_catb( &h->data.request, static_inbuf, l );
130 130
131 if( array_failed( &h->request ) ) 131 if( array_failed( &h->data.request ) )
132 return http_issue_error( clientsocket, CODE_HTTPERROR_500 ); 132 return http_issue_error( clientsocket, CODE_HTTPERROR_500 );
133 133
134 if( array_bytes( &h->request ) > 8192 ) 134 if( array_bytes( &h->data.request ) > 8192 )
135 return http_issue_error( clientsocket, CODE_HTTPERROR_500 ); 135 return http_issue_error( clientsocket, CODE_HTTPERROR_500 );
136 136
137 if( memchr( array_start( &h->request ), '\n', array_bytes( &h->request ) ) ) 137 if( memchr( array_start( &h->data.request ), '\n', array_bytes( &h->data.request ) ) )
138 return http_handle_request( clientsocket, array_start( &h->request ), array_bytes( &h->request ) ); 138 return http_handle_request( clientsocket, array_start( &h->data.request ), array_bytes( &h->data.request ) );
139 139
140 return 0; 140 return 0;
141} 141}
142 142
143static void handle_write( const int64 clientsocket ) { 143static void handle_write( const int64 clientsocket ) {
144 struct http_data* h=io_getcookie( clientsocket ); 144 struct http_data* h=io_getcookie( clientsocket );
145 if( !h || ( iob_send( clientsocket, &h->batch ) <= 0 ) ) 145 if( !h || ( iob_send( clientsocket, &h->data.batch ) <= 0 ) )
146 handle_dead( clientsocket ); 146 handle_dead( clientsocket );
147} 147}
148 148
diff --git a/ot_http.c b/ot_http.c
index 4111d6b..55c524d 100644
--- a/ot_http.c
+++ b/ot_http.c
@@ -53,7 +53,7 @@ static void http_senddata( const int64 client_socket, char *buffer, size_t size
53 /* whoever sends data is not interested in its input-array */ 53 /* whoever sends data is not interested in its input-array */
54 if( h && ( h->flag & STRUCT_HTTP_FLAG_ARRAY_USED ) ) { 54 if( h && ( h->flag & STRUCT_HTTP_FLAG_ARRAY_USED ) ) {
55 h->flag &= ~STRUCT_HTTP_FLAG_ARRAY_USED; 55 h->flag &= ~STRUCT_HTTP_FLAG_ARRAY_USED;
56 array_reset( &h->request ); 56 array_reset( &h->data.request );
57 } 57 }
58 58
59 written_size = write( client_socket, buffer, size ); 59 written_size = write( client_socket, buffer, size );
@@ -69,9 +69,9 @@ static void http_senddata( const int64 client_socket, char *buffer, size_t size
69 return; 69 return;
70 } 70 }
71 71
72 iob_reset( &h->batch ); 72 iob_reset( &h->data.batch );
73 memmove( outbuf, buffer + written_size, size - written_size ); 73 memmove( outbuf, buffer + written_size, size - written_size );
74 iob_addbuf_free( &h->batch, outbuf, size - written_size ); 74 iob_addbuf_free( &h->data.batch, outbuf, size - written_size );
75 h->flag |= STRUCT_HTTP_FLAG_IOB_USED; 75 h->flag |= STRUCT_HTTP_FLAG_IOB_USED;
76 76
77 /* writeable short data sockets just have a tcp timeout */ 77 /* writeable short data sockets just have a tcp timeout */
@@ -124,7 +124,7 @@ ssize_t http_sendiovecdata( const int64 client_socket, int iovec_entries, struct
124 free it now */ 124 free it now */
125 if( h->flag & STRUCT_HTTP_FLAG_ARRAY_USED ) { 125 if( h->flag & STRUCT_HTTP_FLAG_ARRAY_USED ) {
126 h->flag &= ~STRUCT_HTTP_FLAG_ARRAY_USED; 126 h->flag &= ~STRUCT_HTTP_FLAG_ARRAY_USED;
127 array_reset( &h->request ); 127 array_reset( &h->data.request );
128 } 128 }
129 129
130 /* If we came here, wait for the answer is over */ 130 /* If we came here, wait for the answer is over */
@@ -149,12 +149,12 @@ ssize_t http_sendiovecdata( const int64 client_socket, int iovec_entries, struct
149 else 149 else
150 header_size = sprintf( header, "HTTP/1.0 200 OK\r\nContent-Type: text/plain\r\nContent-Length: %zd\r\n\r\n", size ); 150 header_size = sprintf( header, "HTTP/1.0 200 OK\r\nContent-Type: text/plain\r\nContent-Length: %zd\r\n\r\n", size );
151 151
152 iob_reset( &h->batch ); 152 iob_reset( &h->data.batch );
153 iob_addbuf_free( &h->batch, header, header_size ); 153 iob_addbuf_free( &h->data.batch, header, header_size );
154 154
155 /* Will move to ot_iovec.c */ 155 /* Will move to ot_iovec.c */
156 for( i=0; i<iovec_entries; ++i ) 156 for( i=0; i<iovec_entries; ++i )
157 iob_addbuf_munmap( &h->batch, iovector[i].iov_base, iovector[i].iov_len ); 157 iob_addbuf_munmap( &h->data.batch, iovector[i].iov_base, iovector[i].iov_len );
158 free( iovector ); 158 free( iovector );
159 159
160 h->flag |= STRUCT_HTTP_FLAG_IOB_USED; 160 h->flag |= STRUCT_HTTP_FLAG_IOB_USED;
diff --git a/ot_http.h b/ot_http.h
index 4d97769..cd8c3cb 100644
--- a/ot_http.h
+++ b/ot_http.h
@@ -18,7 +18,7 @@ struct http_data {
18 union { 18 union {
19 array request; 19 array request;
20 io_batch batch; 20 io_batch batch;
21 }; 21 } data;
22 char ip[4]; 22 char ip[4];
23 STRUCT_HTTP_FLAG flag; 23 STRUCT_HTTP_FLAG flag;
24}; 24};
diff --git a/ot_mutex.c b/ot_mutex.c
index 8094e99..6edfaef 100644
--- a/ot_mutex.c
+++ b/ot_mutex.c
@@ -19,7 +19,7 @@
19#include "trackerlogic.h" 19#include "trackerlogic.h"
20#include "ot_mutex.h" 20#include "ot_mutex.h"
21 21
22//#define MTX_DBG( STRING ) fprintf( stderr, STRING ) 22/* #define MTX_DBG( STRING ) fprintf( stderr, STRING ) */
23#define MTX_DBG( STRING ) 23#define MTX_DBG( STRING )
24 24
25/* Our global all torrents list */ 25/* Our global all torrents list */
diff --git a/ot_stats.c b/ot_stats.c
index dbab275..31d53e8 100644
--- a/ot_stats.c
+++ b/ot_stats.c
@@ -217,7 +217,6 @@ static size_t stats_slash24s_txt( char * reply, size_t amount, uint32_t thresh )
217 217
218 uint32_t *counts[ NUM_BUFS ]; 218 uint32_t *counts[ NUM_BUFS ];
219 uint32_t slash24s[amount*2]; /* first dword amount, second dword subnet */ 219 uint32_t slash24s[amount*2]; /* first dword amount, second dword subnet */
220// int bucket;
221 size_t i, j, k, l; 220 size_t i, j, k, l;
222 char *r = reply; 221 char *r = reply;
223 222