Mercurial > urweb
comparison src/c/fastcgi.c @ 1997:c93fbd139732
Define uw_loggers structure, allow FFI code to access it
author | Sergey Mironov <grrwlf@gmail.com> |
---|---|
date | Wed, 26 Feb 2014 08:21:52 +0000 |
parents | 9f3597979e98 |
children | 18ef1db770f6 |
comparison
equal
deleted
inserted
replaced
1996:582ea3a4d622 | 1997:c93fbd139732 |
---|---|
322 } | 322 } |
323 | 323 |
324 static void *worker(void *data) { | 324 static void *worker(void *data) { |
325 FCGI_Input *in = fastcgi_input(); | 325 FCGI_Input *in = fastcgi_input(); |
326 FCGI_Output *out = fastcgi_output(); | 326 FCGI_Output *out = fastcgi_output(); |
327 uw_context ctx = uw_request_new_context(*(int *)data, &uw_application, out, log_error, log_debug); | 327 uw_loggers ls = {out, log_error, log_debug}; |
328 uw_context ctx = uw_request_new_context(*(int *)data, &uw_application, &ls); | |
328 uw_request_context rc = uw_new_request_context(); | 329 uw_request_context rc = uw_new_request_context(); |
329 headers hs; | 330 headers hs; |
330 size_t body_size = 0; | 331 size_t body_size = 0; |
331 char *body = malloc(0); | 332 char *body = malloc(0); |
332 size_t path_size = 0; | 333 size_t path_size = 0; |
512 static void sigint(int signum) { | 513 static void sigint(int signum) { |
513 printf("Exiting....\n"); | 514 printf("Exiting....\n"); |
514 exit(0); | 515 exit(0); |
515 } | 516 } |
516 | 517 |
517 static loggers ls = {&uw_application, NULL, log_error, log_debug}; | 518 static uw_loggers ls = {NULL, log_error, log_debug}; |
518 | 519 |
519 int main(int argc, char *argv[]) { | 520 int main(int argc, char *argv[]) { |
520 // The skeleton for this function comes from Beej's sockets tutorial. | 521 // The skeleton for this function comes from Beej's sockets tutorial. |
521 struct sockaddr_in their_addr; // connector's address information | 522 struct sockaddr_in their_addr; // connector's address information |
522 socklen_t sin_size; | 523 socklen_t sin_size; |
561 return 1; | 562 return 1; |
562 } | 563 } |
563 } | 564 } |
564 | 565 |
565 uw_set_on_success(""); | 566 uw_set_on_success(""); |
566 uw_request_init(&uw_application, NULL, log_error, log_debug); | 567 uw_request_init(&uw_application, &ls); |
567 | 568 |
568 names = calloc(nthreads, sizeof(int)); | 569 names = calloc(nthreads, sizeof(int)); |
569 | 570 |
570 sin_size = sizeof their_addr; | 571 sin_size = sizeof their_addr; |
571 | 572 |
572 { | 573 { |
573 pthread_t thread; | 574 pthread_t thread; |
574 | 575 |
575 if (pthread_create_big(&thread, NULL, client_pruner, &ls)) { | 576 pruner_data *pd = (pruner_data *)malloc(sizeof(pruner_data)); |
577 pd->app = &uw_application; | |
578 pd->loggers = &ls; | |
579 | |
580 if (pthread_create_big(&thread, NULL, client_pruner, pd)) { | |
576 fprintf(stderr, "Error creating pruner thread\n"); | 581 fprintf(stderr, "Error creating pruner thread\n"); |
577 return 1; | 582 return 1; |
578 } | 583 } |
579 } | 584 } |
580 | 585 |