Changeset 73860f6fab470281b52162efc311f0c8c40b5e72

Show
Ignore:
Timestamp:
04/22/10 21:56:30 (4 years ago)
Author:
Theo Schlossnagle <jesus@omniti.com>
git-committer:
Theo Schlossnagle <jesus@omniti.com> 1271973390 +0000
git-parent:

[b37e686ef7be37741bc080197b6b119abc4eae31]

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

write an http log on failed write

Files:

Legend:

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

    rb3aacf8 r73860f6  
    200200  return noit_true; 
    201201} 
     202static void 
     203noit_http_log_request(noit_http_session_ctx *ctx) { 
     204  char ip[64], timestr[64]; 
     205  double time_ms; 
     206  struct tm *tm, tbuf; 
     207  time_t now; 
     208  struct timeval end_time, diff; 
     209 
     210  if(ctx->req.start_time.tv_sec == 0) return; 
     211  gettimeofday(&end_time, NULL); 
     212  now = end_time.tv_sec; 
     213  tm = gmtime_r(&now, &tbuf); 
     214  strftime(timestr, sizeof(timestr), "%d/%b/%Y:%H:%M:%S -0000", tm); 
     215  sub_timeval(end_time, ctx->req.start_time, &diff); 
     216  time_ms = diff.tv_sec * 1000 + diff.tv_usec / 1000; 
     217  noit_convert_sockaddr_to_buff(ip, sizeof(ip), &ctx->ac->remote.remote_addr); 
     218  noitL(http_access, "%s - - [%s] \"%s %s %s\" %d %llu %.3f\n", 
     219        ip, timestr, 
     220        ctx->req.method_str, ctx->req.uri_str, ctx->req.protocol_str, 
     221        ctx->res.status_code, 
     222        (long long unsigned)ctx->res.bytes_written, 
     223        time_ms); 
     224} 
     225 
    202226static int 
    203227_http_perform_write(noit_http_session_ctx *ctx, int *mask) { 
     
    238262  if(len == -1) { 
    239263    /* socket error */ 
     264    noit_http_log_request(ctx); 
    240265    ctx->conn.e->opset->close(ctx->conn.e->fd, mask, ctx->conn.e); 
    241266    ctx->conn.e = NULL; 
     
    639664} 
    640665 
    641 static void 
    642 noit_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  
    664666int 
    665667noit_http_session_drive(eventer_t e, int origmask, void *closure,