Show
Ignore:
Timestamp:
04/07/10 02:18:29 (8 years ago)
Author:
Theo Schlossnagle <jesus@omniti.com>
git-committer:
Theo Schlossnagle <jesus@omniti.com> 1270606709 +0000
git-parent:

[1aca1b7f24f7ddd3bb8e44f598a9e0500025d82f]

git-author:
Theo Schlossnagle <jesus@omniti.com> 1270606709 +0000
Message:

pass the acceptor_closure into the noit_http context so we can print out something like common log format

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • src/noit_http.c

    rd1eed0a r37f5a09  
    245245        len, len, b->buff + b->start + ctx->res.output_raw_offset); 
    246246  ctx->res.output_raw_offset += len; 
     247  ctx->res.bytes_written += len; 
    247248  tlen += len; 
    248249  goto choose_bucket; 
     
    258259  if(!req->current_input) req->current_input = req->first_input; 
    259260  if(!req->current_input) return noit_false; 
     261  if(req->start_time.tv_sec == 0) gettimeofday(&req->start_time, NULL); 
    260262 restart: 
    261263  while(req->current_input->prev && 
     
    677679      return mask | maybe_write_mask; 
    678680    } 
    679     noitL(http_access, "HTTP start request (%s)\n", ctx->req.uri_str); 
     681    noitL(http_debug, "HTTP start request (%s)\n", ctx->req.uri_str); 
    680682  } 
    681683 
     
    714716 
    715717noit_http_session_ctx * 
    716 noit_http_session_ctx_new(noit_http_dispatch_func f, void *c, eventer_t e) { 
     718noit_http_session_ctx_new(noit_http_dispatch_func f, void *c, eventer_t e, 
     719                          acceptor_closure_t *ac) { 
    717720  noit_http_session_ctx *ctx; 
    718721  ctx = calloc(1, sizeof(*ctx)); 
     
    723726  ctx->dispatcher_closure = c; 
    724727  ctx->drive = noit_http_session_drive; 
     728  ctx->ac = ac; 
    725729  return ctx; 
    726730} 
     
    10421046noit_boolean 
    10431047noit_http_response_end(noit_http_session_ctx *ctx) { 
    1044   if(ctx->res.output) 
    1045     noitL(http_access, "HTTP finished request (%s)\n", ctx->req.uri_str); 
     1048  if(ctx->res.output) { 
     1049    char ip[64], timestr[64]; 
     1050    double time_ms; 
     1051    struct tm *tm, tbuf; 
     1052    time_t now; 
     1053    struct timeval end_time, diff; 
     1054 
     1055    gettimeofday(&end_time, NULL); 
     1056    now = end_time.tv_sec; 
     1057    tm = gmtime_r(&now, &tbuf); 
     1058    strftime(timestr, sizeof(timestr), "%d/%b/%Y:%H:%M:%S -0000", tm); 
     1059    sub_timeval(end_time, ctx->req.start_time, &diff); 
     1060    time_ms = diff.tv_sec * 1000 + diff.tv_usec / 1000; 
     1061    noit_convert_sockaddr_to_buff(ip, sizeof(ip), &ctx->ac->remote.remote_addr); 
     1062    noitL(http_access, "%s - - [%s] \"%s %s %s\" %d %llu %.3f\n", 
     1063          ip, timestr, 
     1064          ctx->req.method_str, ctx->req.uri_str, ctx->req.protocol_str, 
     1065          ctx->res.status_code, 
     1066          (long long unsigned)ctx->res.bytes_written, 
     1067          time_ms); 
     1068  } 
     1069  ctx->res.bytes_written = 0; 
     1070  ctx->req.start_time.tv_sec = 0L; 
    10461071  if(!noit_http_response_flush(ctx, noit_true)) return noit_false; 
    10471072  return noit_true;