summaryrefslogtreecommitdiff
path: root/ot_udp.c
diff options
context:
space:
mode:
Diffstat (limited to 'ot_udp.c')
-rw-r--r--ot_udp.c31
1 files changed, 30 insertions, 1 deletions
diff --git a/ot_udp.c b/ot_udp.c
index e891494..d3fb82a 100644
--- a/ot_udp.c
+++ b/ot_udp.c
@@ -4,6 +4,8 @@
4 $id$ */ 4 $id$ */
5 5
6/* System */ 6/* System */
7#include <stdlib.h>
8#include <pthread.h>
7#include <string.h> 9#include <string.h>
8#include <arpa/inet.h> 10#include <arpa/inet.h>
9#include <stdio.h> 11#include <stdio.h>
@@ -120,8 +122,35 @@ int handle_udp6( int64 serversocket, struct ot_workstruct *ws ) {
120 return 1; 122 return 1;
121} 123}
122 124
123void udp_init( ) { 125static void* udp_worker( void * args ) {
126 int64 sock = (int64)args;
127 struct ot_workstruct ws;
128 memset( &ws, 0, sizeof(ws) );
129
130 ws.inbuf=malloc(G_INBUF_SIZE);
131 ws.outbuf=malloc(G_OUTBUF_SIZE);
132#ifdef _DEBUG_HTTPERROR
133 ws.debugbuf=malloc(G_DEBUGBUF_SIZE);
134#endif
135
136 while( g_opentracker_running )
137 handle_udp6( sock, &ws );
138
139 free( ws.inbuf );
140 free( ws.outbuf );
141#ifdef _DEBUG_HTTPERROR
142 free( ws.debugbuf );
143#endif
144 return NULL;
145}
124 146
147void udp_init( int64 sock, unsigned int worker_count ) {
148 pthread_t thread_id;
149#ifdef _DEBUG
150 fprintf( stderr, " installing %d workers on udp socket %ld", worker_count, (unsigned long)sock );
151#endif
152 while( worker_count-- )
153 pthread_create( &thread_id, NULL, udp_worker, (void *)sock );
125} 154}
126 155
127const char *g_version_udp_c = "$Source$: $Revision$\n"; 156const char *g_version_udp_c = "$Source$: $Revision$\n";