comparison src/c/fastcgi.c @ 1094:db52c32dbe42

All three current protocols work with move to using uw_app
author Adam Chlipala <adamc@hcoop.net>
date Sun, 27 Dec 2009 10:37:24 -0500
parents c2317cfb99ec
children 0cee0c8d8c37
comparison
equal deleted inserted replaced
1093:8d3aa6c7cee0 1094:db52c32dbe42
8 #include <netdb.h> 8 #include <netdb.h>
9 #include <netinet/in.h> 9 #include <netinet/in.h>
10 #include <unistd.h> 10 #include <unistd.h>
11 #include <signal.h> 11 #include <signal.h>
12 #include <stdarg.h> 12 #include <stdarg.h>
13 #include <ctype.h>
13 14
14 #include <pthread.h> 15 #include <pthread.h>
15 16
16 #include "urweb.h" 17 #include "urweb.h"
17 #include "request.h" 18 #include "request.h"
18 #include "queue.h" 19 #include "queue.h"
19 20
20 #include "fastcgi.h" 21 #include "fastcgi.h"
22
23 extern uw_app uw_application;
21 24
22 typedef struct { 25 typedef struct {
23 unsigned char version; 26 unsigned char version;
24 unsigned char type; 27 unsigned char type;
25 unsigned char requestIdB1; 28 unsigned char requestIdB1;
298 301
299 static void *worker(void *data) { 302 static void *worker(void *data) {
300 int me = *(int *)data; 303 int me = *(int *)data;
301 FCGI_Input *in = fastcgi_input(); 304 FCGI_Input *in = fastcgi_input();
302 FCGI_Output *out = fastcgi_output(); 305 FCGI_Output *out = fastcgi_output();
303 uw_context ctx = uw_request_new_context(out, log_error, log_debug); 306 uw_context ctx = uw_request_new_context(&uw_application, out, log_error, log_debug);
304 uw_request_context rc = uw_new_request_context(); 307 uw_request_context rc = uw_new_request_context();
305 headers hs; 308 headers hs;
306 size_t body_size = 0; 309 size_t body_size = 0;
307 char *body = malloc(0); 310 char *body = malloc(0);
308 size_t path_size = 0; 311 size_t path_size = 0;
487 static void sigint(int signum) { 490 static void sigint(int signum) {
488 printf("Exiting....\n"); 491 printf("Exiting....\n");
489 exit(0); 492 exit(0);
490 } 493 }
491 494
492 static loggers ls = {NULL, log_error, log_debug}; 495 static loggers ls = {&uw_application, NULL, log_error, log_debug};
493 496
494 int main(int argc, char *argv[]) { 497 int main(int argc, char *argv[]) {
495 // The skeleton for this function comes from Beej's sockets tutorial. 498 // The skeleton for this function comes from Beej's sockets tutorial.
496 struct sockaddr_in their_addr; // connector's address information 499 struct sockaddr_in their_addr; // connector's address information
497 int sin_size, yes = 1; 500 int sin_size, yes = 1;
536 return 1; 539 return 1;
537 } 540 }
538 } 541 }
539 542
540 uw_set_on_success(""); 543 uw_set_on_success("");
541 uw_request_init(NULL, log_error, log_debug); 544 uw_request_init(&uw_application, NULL, log_error, log_debug);
542 545
543 names = calloc(nthreads, sizeof(int)); 546 names = calloc(nthreads, sizeof(int));
544 547
545 sin_size = sizeof their_addr; 548 sin_size = sizeof their_addr;
546 549