CVS diff for response.c between 1.18 and 1.16:

Revision 1.16 Revision 1.18
Line 77 Line 77
int r412_len, r413_len, r414_len, r415_len, r416_len, r417_len, r500_len; 
int r501_len, r502_len, r503_len, r504_len, r505_len; 
 
int r412_len, r413_len, r414_len, r415_len, r416_len, r417_len, r500_len; 
int r501_len, r502_len, r503_len, r504_len, r505_len; 
 
#ifdef RESPONSE_CONCURRENCY
/* Number of threads sending data right now */
int active_responders = 0;
#endif
 
 
/* initialize static reply contents */ 
/* for now, we use pth version */ 
#define SERVER_STRING "cow" 
/* initialize static reply contents */ 
/* for now, we use pth version */ 
#define SERVER_STRING "cow" 
Line 91 Line 86
 * Some things never change...keep these in a static memory buffer.  Note that 
* the final header in this string should not include the \r\n line terminator. 
*/ 
 * Some things never change...keep these in a static memory buffer.  Note that 
* the final header in this string should not include the \r\n line terminator. 
*/ 
static char constant_headers[] = "Server: " SERVER_STRING "/" VERSION ", Pth " PTH_VERSION_STR; 
static char constant_headers[] = "Server: " SERVER_STRING "/" VERSION ", Pth " PTH_VERSION_STR "\r\n"; 
static int constant_headers_len; 
 
/* Variables used by setsockopt */ 
static int constant_headers_len; 
 
/* Variables used by setsockopt */ 
Line 104 Line 99
            "Connection: close\r\n"                 \ 
"Content-type: text/plain\r\n" \ 
"Content-Length: %d\r\n" \ 
            "Connection: close\r\n"                 \ 
"Content-type: text/plain\r\n" \ 
"Content-Length: %d\r\n" \ 
            "%s\r\n"                                \ 
            "%s"                                    \ 
            "\r\n"                                  \ 
BODY, strlen(BODY), constant_headers); \ 
BUF##_len = strlen(BUF); \ 
            "\r\n"                                  \ 
BODY, strlen(BODY), constant_headers); \ 
BUF##_len = strlen(BUF); \ 
Line 369 Line 364
 
// fix here s.t. proper header (ie. keepalive etc) would be generated. 
// request is GET, and uri found, so compose a header for 200 
 
// fix here s.t. proper header (ie. keepalive etc) would be generated. 
// request is GET, and uri found, so compose a header for 200 
    send_header_200(req);	// add keepalive to this func.

    if (M_HEAD == req->p_method) {
    send_header_200(req);

    if (M_HEAD == req->p_method) 
        /* We've already written the headers so just close the connection */
	COW_CLOSE(req->fdd);
 
        return 0;
        return 0;
 
 
#ifdef USE_SENDFILE 
/* 
 
#ifdef USE_SENDFILE 
/* 
Line 430 Line 422
            return -1; 

 
            return -1; 

 
#ifdef RESPONSE_CONCURRENCY
        /* Don't respond until there are few enough other responding threads */
        while (active_responders >= RESPONSE_CONCURRENCY)
            pth_yield(NULL);
        active_responders++;
#endif
 
 
        /* Send the body of the requested page */ 
sent = cow_write(req->fdp, m, req->r_filesize); 
if (sent < req->r_filesize) { 
        /* Send the body of the requested page */ 
sent = cow_write(req->fdp, m, req->r_filesize); 
if (sent < req->r_filesize) { 
Line 452 Line 437
#endif /* LOGGING */ 

 
#endif /* LOGGING */ 

 
#ifdef RESPONSE_CONCURRENCY
        /* Done responding; update # of active responders */
        active_responders--;
#endif
 
 
        /* Unmap the file from memory */ 
if (munmap(m, length)) 
perror("munmap"); 
        /* Unmap the file from memory */ 
if (munmap(m, length)) 
perror("munmap"); 
Line 484 Line 464
 
time(&mytime); 
mytm = (struct tm *)gmtime(&mytime); 
 
time(&mytime); 
mytm = (struct tm *)gmtime(&mytime); 
    strftime(s, 128, "%d %b %Y %H:%M %Z", mytm);	// shortest possible 
    strftime(s, 128, "%d %b %Y %H:%M %Z\r\n", mytm);	// shortest possible 
 
cow_write(req->fdp, "Date: ", 6); 
cow_write(req->fdp, s, strlen(s)); 
 
cow_write(req->fdp, "Date: ", 6); 
cow_write(req->fdp, s, strlen(s)); 
Line 518 Line 498
// inline 
void send_keepalive_lines(msg * req) 
// inline 
void send_keepalive_lines(msg * req) 
/*
  if (req->ka_count >0
  &&  req->ka_status == KA_ACTIVE
  )
//&&  req->response_status < 500)
  {
    char buf_ka_timeout[32];
    char buf_ka_count[32];
    sprintf(buf_ka_timeout, "timeout=%lu, ", ka_max_dur);
    sprintf(buf_ka_count,   "max=%d\r\n", req->ka_count);
    strcat(req->r_buf, "Connection: Keep-Alive\r\nKeep-Alive: timeout=15\r\n");
  }
  else
*/ 
#ifndef DISABLE_KEEPALIVE
    if (req->ka_count >0 && req->ka_status == KA_ACTIVE) {
        char buf_ka_timeout[32];
        char buf_ka_count[32];
        int bkt_len, bkc_len;
        bkt_len = sprintf(buf_ka_timeout, "timeout=%lu, ", ka_max_dur);
        bkc_len = sprintf(buf_ka_count,   "max=%d\r\n", req->ka_count);
        cow_write(req->fdp, "Connection: Keep-Alive\r\nKeep-Alive: ", 36);
        cow_write(req->fdp, buf_ka_timeout, bkt_len);
        cow_write(req->fdp, buf_ka_count, bkc_len);
    } else {
        req->ka_status = KA_INACTIVE;
        cow_write(req->fdp, "Connection: close\r\n", 19);
    }
#else 
    req->ka_status = KA_INACTIVE; 
cow_write(req->fdp, "Connection: close\r\n", 19);
    req->ka_status = KA_INACTIVE; 
cow_write(req->fdp, "Connection: close\r\n", 19);
    //strcat(req->r_buf, "Connection: close\r\n"); 
#endif 

 
 

 
 
Line 641 Line 621
    --cow_noof;                                                 \ 

 
    --cow_noof;                                                 \ 

 


Legend
Lines deleted from 1.18  
Lines Modified
  Lines added in revision 1.16