cgi: Use worker_spawn to conserve thread resources (detached)
authorLauri Kasanen <cand@gmx.com>
Thu, 14 Jun 2012 14:46:04 +0000 (17:46 +0300)
committerEduardo Silva <edsiper@gmail.com>
Thu, 14 Jun 2012 16:03:17 +0000 (10:03 -0600)
Signed-off-by: Lauri Kasanen <cand@gmx.com>
Signed-off-by: Eduardo Silva <edsiper@gmail.com>

plugins/cgi/cgi.c

index ce32690..0d68fcb 100644 (file)
@@ -63,14 +63,12 @@ static int swrite(const int fd, const void *buf, const size_t count)
     return 1;
 }
 
-static void *cgi_write_post(void *p)
+static void cgi_write_post(void *p)
 {
     const struct post_t * const in = p;
 
     swrite(in->fd, in->buf, in->len);
     close(in->fd);
-
-    return NULL;
 }
 
 static int do_cgi(const char * const __restrict__ file, const char * const __restrict__ url,
@@ -228,9 +226,7 @@ static int do_cgi(const char * const __restrict__ file, const char * const __res
         p.buf = sr->data.data;
         p.len = sr->data.len;
 
-        pthread_t tid;
-
-        pthread_create(&tid, NULL, cgi_write_post, &p);
+        mk_api->worker_spawn(cgi_write_post, &p);
     }
 
     char buf[PATHLEN], *outptr;