summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--opentracker.c24
-rw-r--r--ot_http.c16
-rw-r--r--ot_http.h2
-rw-r--r--ot_mutex.c4
-rw-r--r--ot_stats.c3
5 files changed, 24 insertions, 25 deletions
diff --git a/opentracker.c b/opentracker.c
index 54a7290..62e8c1f 100644
--- a/opentracker.c
+++ b/opentracker.c
@@ -2,7 +2,7 @@
It is considered beerware. Prost. Skol. Cheers or whatever.
Some of the stuff below is stolen from Fefes example libowfat httpd.
- $Id: opentracker.c,v 1.207 2009/01/02 08:57:49 erdgeist Exp $ */
+ $Id: opentracker.c,v 1.208 2009/01/03 03:25:37 erdgeist Exp $ */
/* System */
#include <stdlib.h>
@@ -97,9 +97,9 @@ static void handle_dead( const int64 socket ) {
struct http_data* h=io_getcookie( socket );
if( h ) {
if( h->flag & STRUCT_HTTP_FLAG_IOB_USED )
- iob_reset( &h->batch );
+ iob_reset( &h->data.batch );
if( h->flag & STRUCT_HTTP_FLAG_ARRAY_USED )
- array_reset( &h->request );
+ array_reset( &h->data.request );
if( h->flag & STRUCT_HTTP_FLAG_WAITINGFORTASK )
mutex_workqueue_canceltask( socket );
free( h );
@@ -117,32 +117,32 @@ static ssize_t handle_read( const int64 clientsocket ) {
}
/* If we get the whole request in one packet, handle it without copying */
- if( !array_start( &h->request ) ) {
+ if( !array_start( &h->data.request ) ) {
if( memchr( static_inbuf, '\n', l ) )
return http_handle_request( clientsocket, static_inbuf, l );
h->flag |= STRUCT_HTTP_FLAG_ARRAY_USED;
- array_catb( &h->request, static_inbuf, l );
+ array_catb( &h->data.request, static_inbuf, l );
return 0;
}
h->flag |= STRUCT_HTTP_FLAG_ARRAY_USED;
- array_catb( &h->request, static_inbuf, l );
+ array_catb( &h->data.request, static_inbuf, l );
- if( array_failed( &h->request ) )
+ if( array_failed( &h->data.request ) )
return http_issue_error( clientsocket, CODE_HTTPERROR_500 );
- if( array_bytes( &h->request ) > 8192 )
+ if( array_bytes( &h->data.request ) > 8192 )
return http_issue_error( clientsocket, CODE_HTTPERROR_500 );
- if( memchr( array_start( &h->request ), '\n', array_bytes( &h->request ) ) )
- return http_handle_request( clientsocket, array_start( &h->request ), array_bytes( &h->request ) );
+ if( memchr( array_start( &h->data.request ), '\n', array_bytes( &h->data.request ) ) )
+ return http_handle_request( clientsocket, array_start( &h->data.request ), array_bytes( &h->data.request ) );
return 0;
}
static void handle_write( const int64 clientsocket ) {
struct http_data* h=io_getcookie( clientsocket );
- if( !h || ( iob_send( clientsocket, &h->batch ) <= 0 ) )
+ if( !h || ( iob_send( clientsocket, &h->data.batch ) <= 0 ) )
handle_dead( clientsocket );
}
@@ -463,4 +463,4 @@ while( scanon ) {
return 0;
}
-const char *g_version_opentracker_c = "$Source: /home/cvsroot/opentracker/opentracker.c,v $: $Revision: 1.207 $\n";
+const char *g_version_opentracker_c = "$Source: /home/cvsroot/opentracker/opentracker.c,v $: $Revision: 1.208 $\n";
diff --git a/ot_http.c b/ot_http.c
index eb8aba8..a4f2e25 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
/* whoever sends data is not interested in its input-array */
if( h && ( h->flag & STRUCT_HTTP_FLAG_ARRAY_USED ) ) {
h->flag &= ~STRUCT_HTTP_FLAG_ARRAY_USED;
- array_reset( &h->request );
+ array_reset( &h->data.request );
}
written_size = write( client_socket, buffer, size );
@@ -69,9 +69,9 @@ static void http_senddata( const int64 client_socket, char *buffer, size_t size
return;
}
- iob_reset( &h->batch );
+ iob_reset( &h->data.batch );
memmove( outbuf, buffer + written_size, size - written_size );
- iob_addbuf_free( &h->batch, outbuf, size - written_size );
+ iob_addbuf_free( &h->data.batch, outbuf, size - written_size );
h->flag |= STRUCT_HTTP_FLAG_IOB_USED;
/* 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
free it now */
if( h->flag & STRUCT_HTTP_FLAG_ARRAY_USED ) {
h->flag &= ~STRUCT_HTTP_FLAG_ARRAY_USED;
- array_reset( &h->request );
+ array_reset( &h->data.request );
}
/* 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
else
header_size = sprintf( header, "HTTP/1.0 200 OK\r\nContent-Type: text/plain\r\nContent-Length: %zd\r\n\r\n", size );
- iob_reset( &h->batch );
- iob_addbuf_free( &h->batch, header, header_size );
+ iob_reset( &h->data.batch );
+ iob_addbuf_free( &h->data.batch, header, header_size );
/* Will move to ot_iovec.c */
for( i=0; i<iovec_entries; ++i )
- iob_addbuf_munmap( &h->batch, iovector[i].iov_base, iovector[i].iov_len );
+ iob_addbuf_munmap( &h->data.batch, iovector[i].iov_base, iovector[i].iov_len );
free( iovector );
h->flag |= STRUCT_HTTP_FLAG_IOB_USED;
@@ -567,4 +567,4 @@ ssize_t http_handle_request( const int64 client_socket, char *data, size_t recv_
return reply_size;
}
-const char *g_version_http_c = "$Source: /home/cvsroot/opentracker/ot_http.c,v $: $Revision: 1.24 $\n";
+const char *g_version_http_c = "$Source: /home/cvsroot/opentracker/ot_http.c,v $: $Revision: 1.25 $\n";
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 {
union {
array request;
io_batch batch;
- };
+ } data;
char ip[4];
STRUCT_HTTP_FLAG flag;
};
diff --git a/ot_mutex.c b/ot_mutex.c
index a876b1a..467886d 100644
--- a/ot_mutex.c
+++ b/ot_mutex.c
@@ -19,7 +19,7 @@
#include "trackerlogic.h"
#include "ot_mutex.h"
-//#define MTX_DBG( STRING ) fprintf( stderr, STRING )
+/* #define MTX_DBG( STRING ) fprintf( stderr, STRING ) */
#define MTX_DBG( STRING )
/* Our global all torrents list */
@@ -326,4 +326,4 @@ void mutex_deinit( ) {
byte_zero( all_torrents, sizeof( all_torrents ) );
}
-const char *g_version_mutex_c = "$Source: /home/cvsroot/opentracker/ot_mutex.c,v $: $Revision: 1.16 $\n";
+const char *g_version_mutex_c = "$Source: /home/cvsroot/opentracker/ot_mutex.c,v $: $Revision: 1.17 $\n";
diff --git a/ot_stats.c b/ot_stats.c
index 9580023..5c27c2a 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 )
uint32_t *counts[ NUM_BUFS ];
uint32_t slash24s[amount*2]; /* first dword amount, second dword subnet */
-// int bucket;
size_t i, j, k, l;
char *r = reply;
@@ -616,4 +615,4 @@ void stats_deinit( ) {
pthread_cancel( thread_id );
}
-const char *g_version_stats_c = "$Source: /home/cvsroot/opentracker/ot_stats.c,v $: $Revision: 1.34 $\n";
+const char *g_version_stats_c = "$Source: /home/cvsroot/opentracker/ot_stats.c,v $: $Revision: 1.35 $\n";