Show
Ignore:
Timestamp:
04/07/10 03:14:57 (9 years ago)
Author:
Theo Schlossnagle <jesus@omniti.com>
git-committer:
Theo Schlossnagle <jesus@omniti.com> 1270610097 +0000
git-parent:

[37f5a09eba7361266c79ca6fdecd3851336934c8]

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

move the logging into position after the response is flushed.

Files:

Legend:

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

    r37f5a09 rb3aacf8  
    638638  return bytes_read; 
    639639} 
     640 
     641static void 
     642noit_http_log_request(noit_http_session_ctx *ctx) { 
     643  char ip[64], timestr[64]; 
     644  double time_ms; 
     645  struct tm *tm, tbuf; 
     646  time_t now; 
     647  struct timeval end_time, diff; 
     648 
     649  gettimeofday(&end_time, NULL); 
     650  now = end_time.tv_sec; 
     651  tm = gmtime_r(&now, &tbuf); 
     652  strftime(timestr, sizeof(timestr), "%d/%b/%Y:%H:%M:%S -0000", tm); 
     653  sub_timeval(end_time, ctx->req.start_time, &diff); 
     654  time_ms = diff.tv_sec * 1000 + diff.tv_usec / 1000; 
     655  noit_convert_sockaddr_to_buff(ip, sizeof(ip), &ctx->ac->remote.remote_addr); 
     656  noitL(http_access, "%s - - [%s] \"%s %s %s\" %d %llu %.3f\n", 
     657        ip, timestr, 
     658        ctx->req.method_str, ctx->req.uri_str, ctx->req.protocol_str, 
     659        ctx->res.status_code, 
     660        (long long unsigned)ctx->res.bytes_written, 
     661        time_ms); 
     662} 
     663 
    640664int 
    641665noit_http_session_drive(eventer_t e, int origmask, void *closure, 
     
    694718     ctx->conn.needs_close == noit_true) { 
    695719   abort_drive: 
     720    noit_http_log_request(ctx); 
    696721    ctx->conn.e->opset->close(ctx->conn.e->fd, &mask, ctx->conn.e); 
    697722    ctx->conn.e = NULL; 
     
    699724  } 
    700725  if(ctx->res.complete == noit_true) { 
     726    noit_http_log_request(ctx); 
    701727    noit_http_request_release(ctx); 
    702728    noit_http_response_release(ctx); 
     
    10441070  return ctx->conn.e ? noit_true : noit_false; 
    10451071} 
     1072 
    10461073noit_boolean 
    10471074noit_http_response_end(noit_http_session_ctx *ctx) { 
    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; 
    10711075  if(!noit_http_response_flush(ctx, noit_true)) return noit_false; 
    10721076  return noit_true;