CVS diff for hand.c between 1.9 and 1.7:

Revision 1.7 Revision 1.9
Line 9 Line 9
#include "http_message.h" 
#include "defines.h" // refers to #define MAXREQLINE 1024 
 
#include "http_message.h" 
#include "defines.h" // refers to #define MAXREQLINE 1024 
 
 
//#define HAND_ACCOUNTING
 
/* 
* The HTTP request handler 
*/ 
/* 
* The HTTP request handler 
*/ 
Line 17 Line 19
    // pth related vars 
pth_t my_id = (pth_t) NULL; 
char my_name[16]; // 64-bit machine use 16 here? 8 is fine on 32bit pc 
    // pth related vars 
pth_t my_id = (pth_t) NULL; 
char my_name[16]; // 64-bit machine use 16 here? 8 is fine on 32bit pc 
    pth_msgport_t depot; 
    pth_msgport_t depot = NULL; 
    pth_msgport_t mp; 
pth_event_t ev; 
pmsg pm_msg; 
    pth_msgport_t mp; 
pth_event_t ev; 
pmsg pm_msg; 
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 40 Line 42

 
/* Wait for the depot's message port to become available */ 

 
/* Wait for the depot's message port to become available */ 
    while (NULL == (depot = pth_msgport_find(DEPOT))) 
    depot = pth_msgport_find(DEPOT);
 
    while (NULL == depot) {
        pth_yield(NULL);
        pth_yield(NULL);
 
        depot = pth_msgport_find(DEPOT);
    } 
 
/* 
* Send an initial "request finished" message to the depot. This will 
 
/* 
* Send an initial "request finished" message to the depot. This will 
Line 66 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;
#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); 
assert(pp_msg != NULL); 
        /* Get the request message from our message port */ 
pp_msg = (pmsg *) pth_msgport_get(mp); 
assert(pp_msg != NULL); 
        /* Extract the file descriptor */ 
        /* Extract the file descriptor / transaction buffer */
 
#ifdef USE_TCPCORK
        req_msg.fdp = pp_msg->fd;
        req_msg.fdp = pp_msg->fd;
 
#else
        req_msg.fdp = pp_msg->buf;
#endif 
 
/* We're done with the pmsg structure now; return it to the pool */ 
rn = (reqnode*)pp_msg; 
 
/* We're done with the pmsg structure now; return it to the pool */ 
rn = (reqnode*)pp_msg; 
Line 84 Line 102
 
/* Read and process the request */ 
ret_val = read_request(&req_msg); 
 
/* Read and process the request */ 
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 99 Line 123
    return _arg; 

 
    return _arg; 

 
/*
 * handler is per thread spawned for each request.
 * This is still here just for ref or debug purpose.
 */
#if 0
void *handler(void *_arg)
{

    int fd = (int)((long)_arg);
    int msgsize;

    msg req_msg;
    msg *new_req_msg;

    req_msg.fdp = fd;
    msgsize = read_request(&req_msg);
    printf("read_request() returned %d\n", msgsize);

    // to make sure
/*
  { extern int cow_noof;
  COW_CLOSE(req_msg.fdp)
  COW_CLOSE(req_msg.fdd)
  }
*/

    pth_abort(pth_self());
    pth_exit(NULL);
    return (void *)NULL;
}
#endif /* 0 */
 
 


Legend
Lines deleted from 1.9  
Lines Modified
  Lines added in revision 1.7