diff options
author | Sergey Mironov <grrwlf@gmail.com> | 2014-02-26 08:21:52 +0000 |
---|---|---|
committer | Sergey Mironov <grrwlf@gmail.com> | 2014-02-26 08:21:52 +0000 |
commit | 640c7fe665f5f37fed005b2c9fe96c4818cc7043 (patch) | |
tree | 862a66aa60eaf19fe465d3f7a5e0830d69fb81f3 /src/c/http.c | |
parent | f79fb21d3b1c01b92b96cc813c6ccde66a1fbe79 (diff) |
Define uw_loggers structure, allow FFI code to access it
Diffstat (limited to 'src/c/http.c')
-rw-r--r-- | src/c/http.c | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/src/c/http.c b/src/c/http.c index 25d2a320..32dd1dd1 100644 --- a/src/c/http.c +++ b/src/c/http.c @@ -70,9 +70,11 @@ static void log_debug(void *data, const char *fmt, ...) { } } +static uw_loggers ls = {NULL, log_error, log_debug}; + static void *worker(void *data) { int me = *(int *)data; - uw_context ctx = uw_request_new_context(me, &uw_application, NULL, log_error, log_debug); + uw_context ctx = uw_request_new_context(me, &uw_application, &ls); size_t buf_size = 1024; char *buf = malloc(buf_size), *back = buf; uw_request_context rc = uw_new_request_context(); @@ -307,8 +309,6 @@ static void sigint(int signum) { exit(0); } -static loggers ls = {&uw_application, NULL, log_error, log_debug}; - int main(int argc, char *argv[]) { // The skeleton for this function comes from Beej's sockets tutorial. int sockfd; // listen on sock_fd @@ -374,7 +374,7 @@ int main(int argc, char *argv[]) { } } - uw_request_init(&uw_application, NULL, log_error, log_debug); + uw_request_init(&uw_application, &ls); names = calloc(nthreads, sizeof(int)); @@ -411,7 +411,11 @@ int main(int argc, char *argv[]) { { pthread_t thread; - if (pthread_create_big(&thread, NULL, client_pruner, &ls)) { + pruner_data *pd = (pruner_data *)malloc(sizeof(pruner_data)); + pd->app = &uw_application; + pd->loggers = &ls; + + if (pthread_create_big(&thread, NULL, client_pruner, pd)) { fprintf(stderr, "Error creating pruner thread\n"); return 1; } |