]> git.ipfire.org Git - thirdparty/opentracker.git/commitdiff
-m64 is not usually a correct compile option
authorerdgeist <>
Sat, 20 Jan 2007 01:50:28 +0000 (01:50 +0000)
committererdgeist <>
Sat, 20 Jan 2007 01:50:28 +0000 (01:50 +0000)
Makefile
README
opentracker.c
testsuite.sh

index 94b8e05e805b21a9bdd712b6ecffb3a00ef6b33c..74c5db56b19badb24b2b8b267c4e04fd8f102d6c 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -2,7 +2,7 @@ CC?=gcc
 FEATURES=#-D_DEBUG_FDS -DWANT_IP_FROM_QUERY_STRING -DWANT_BLACKLIST -DWANT_CLOSED_TRACKER
 #DEBUG_OPTS=-g -ggdb -pg # -fprofile-arcs -ftest-coverage
 DEBUG_OPTS=-s -Os
-CFLAGS+=-I../libowfat -Wall -pipe -m64 # -pedantic -ansi
+CFLAGS+=-I../libowfat -Wall -pipe # -pedantic -ansi
 LDFLAGS+=-L../libowfat/ -lowfat -lm
 
 HEADERS=trackerlogic.h scan_urlencoded_query.h
diff --git a/README b/README
index c90db43030e454a29e8913e4b320e33a13b76a2c..1890400ff9b92aec63cd372c26de23f8669960f4 100644 (file)
--- a/README
+++ b/README
@@ -26,3 +26,7 @@ sysctl kern.ipc.somaxconn=1024
 sysctl kern.ipc.nmbclusters=32768
 sysctl net.inet.tcp.msl=10000
 sysctl kern.maxfiles=10240
+
+License information:
+
+Although the libowfat library is under GPL, Felix von Leitner aggreed that the compiled binary may be distributed under the same beer ware license as the source code for opentracker. However, we like to hear from happy customers.
index 374824f4406082fdb68a6db012aac008c99eaa84..6ff9da3d92e61ab34cf2bdcb24de62070de7c31f 100644 (file)
@@ -5,6 +5,7 @@
 
 #include "socket.h"
 #include "io.h"
+#include "iob.h"
 #include "buffer.h"
 #include "array.h"
 #include "byte.h"
@@ -52,7 +53,10 @@ static void panic(const char* routine) {
 }
 
 struct http_data {
-  array r;
+  union {
+    array    r;
+    io_batch batch;
+  };
   unsigned char ip[4];
 };
 
@@ -81,12 +85,24 @@ void senddata(int64 s, struct http_data* h, char *buffer, size_t size ) {
     free(h); io_close( s );
   } else {
     /* here we would take a copy of the buffer and remember it */
-    fprintf( stderr, "Should have handled this.\n" );
+    char * outbuf = malloc( size - written_size );
+    tai6464 t;
+
+    if( !outbuf ) {
 #ifdef _DEBUG_FDS
-  if( !fd_debug_space[s] ) fprintf( stderr, "close on non-open fd\n" );
-  fd_debug_space[s] = 0;
+      if( !fd_debug_space[s] ) fprintf( stderr, "close on non-open fd\n" );
+      fd_debug_space[s] = 0;
 #endif
-    free(h); io_close( s );
+      free(h); io_close( s );
+      return;
+    }
+
+    iob_reset( &h->batch );
+    memmove( outbuf, buffer + written_size, size - written_size );
+    iob_addbuf_free( &h->batch, outbuf, size - written_size );
+
+    // writeable sockets just have a tcp timeout
+    taia_uint(&t,0); io_timeout( s, t );
   }
 }
 
@@ -437,6 +453,16 @@ void handle_read( int64 clientsocket ) {
     httpresponse(clientsocket,h);
 }
 
+void handle_write( int64 clientsocket ) {
+  struct http_data* h=io_getcookie(clientsocket);
+  if( !h ) return;
+  if( iob_send( clientsocket, &h->batch ) <= 0 ) {
+    iob_reset( &h->batch );
+    io_close( clientsocket );
+    free( h );
+  }
+}
+
 void handle_accept( int64 serversocket ) {
   struct http_data* h;
   unsigned char ip[4];
@@ -510,6 +536,9 @@ void server_mainloop( int64 serversocket ) {
         handle_read( i );
     }
 
+    while( ( i = io_canwrite() ) != -1 )
+      handle_write( i );
+
     taia_now(&t);
     if( taia_less( &next_timeout_check, &t ) ) {
       handle_timeouted( );
index e5bc7a48d0f9b53744cba1a0501d3c0f0348a2af..6baeabbdc03a98af9437301a1a90a075003e1311 100644 (file)
@@ -6,7 +6,7 @@ ip=10.1.1.$(( $RANDOM & 0xff ))&port=$(( $RANDOM & 0xff )) HTTP/1.0\n"
 
 #  echo -e $request_string
 #  echo
-  echo -e $request_string | nc 127.0.0.1 6969 >/dev/null
+  echo -e $request_string | nc 127.0.0.1 6969 >/dev/null &
 #  echo
 
 done