Revision 1.8 |
Revision 1.9 |
Line 8 |
Line 8 |
#include "request.h" #include "http_message.h" #include "defines.h" // refers to #define MAXREQLINE 1024 
|
#include "request.h" #include "http_message.h" #include "defines.h" // refers to #define MAXREQLINE 1024 
|
|
//#define HAND_ACCOUNTING
|
/* * The HTTP request handler
|
/* * The HTTP request handler
|
Line 32 |
Line 34 |
* requests to us. */ my_id = pth_self();
|
* requests to us. */ my_id = pth_self();
|
sprintf(my_name, "%x", (int)my_id);
|
sprintf(my_name, "hand%d", (int)_arg);
|
mp = pth_msgport_create(my_name); if (mp == NULL) { perror("Failed to create message port for handler");
|
mp = pth_msgport_create(my_name); if (mp == NULL) { perror("Failed to create message port for handler");
|
Line 69 |
Line 71 |
ev = pth_event(PTH_EVENT_MSG, mp); for (;;) { reqnode* rn;
|
ev = pth_event(PTH_EVENT_MSG, mp); for (;;) { reqnode* rn;
|
|
#ifdef HAND_ACCOUNTING
|
struct timeval t1, t2;
|
struct timeval t1, t2;
|
|
#endif
|
/* Wait for a request to be dispatched to us */ pth_wait(ev);
|
/* Wait for a request to be dispatched to us */ pth_wait(ev);
|
|
#ifdef HAND_ACCOUNTING
gettimeofday(&t1, NULL);
printf("%s starting back up after %d ms delay.\n", my_name, (t1.tv_sec - t2.tv_sec)*1000 + (t1.tv_usec - t2.tv_usec)/1000);
#endif
|
/* Get the request message from our message port */ pp_msg = (pmsg *) pth_msgport_get(mp);
|
/* Get the request message from our message port */ pp_msg = (pmsg *) pth_msgport_get(mp);
|
Line 94 |
Line 104 |
ret_val = read_request(&req_msg); cow_tot_served++;
|
ret_val = read_request(&req_msg); cow_tot_served++;
|
|
#ifdef HAND_ACCOUNTING
gettimeofday(&t2, NULL);
printf("%s finished after %d ms delay.\n", my_name, (t2.tv_sec - t1.tv_sec)*1000 + (t2.tv_usec - t1.tv_usec)/1000);
#endif
|
/* * Send a message to the depot to put this thread back on the 'idle * handler' stack.
|
/* * Send a message to the depot to put this thread back on the 'idle * handler' stack.
|
Line 108 |
Line 123 |
return _arg; }
|
return _arg; }
|