Changeset d1eed0a31060e85817e7ca2188361aafcf6f115e

Show
Ignore:
Timestamp:
04/06/10 21:47:59 (5 years ago)
Author:
Theo Schlossnagle <jesus@omniti.com>
git-committer:
Theo Schlossnagle <jesus@omniti.com> 1270590479 +0000
git-parent:

[fddf7172a39575dd9460f878ba73e3b42e8f8154]

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

loggers for http and critical but if pipelined payload, we weren't shortening the input buffer once we dissected out the payload post-headers

Files:

Legend:

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

    rfddf717 rd1eed0a  
    4646#define HEADER_EXPECT "expect" 
    4747 
     48static noit_log_stream_t http_debug = NULL; 
     49static noit_log_stream_t http_io = NULL; 
     50static noit_log_stream_t http_access = NULL; 
     51 
    4852#define CTX_ADD_HEADER(a,b) \ 
    4953    noit_hash_replace(&ctx->res.headers, \ 
     
    238242    return -1; 
    239243  } 
     244  noitL(http_io, " http_write(%d) => %d [\n%.*s\n]\n", ctx->conn.e->fd, 
     245        len, len, b->buff + b->start + ctx->res.output_raw_offset); 
    240246  ctx->res.output_raw_offset += len; 
    241247  tlen += len; 
     
    284290 match: 
    285291  req->current_request_chain = req->first_input; 
    286   noitL(noit_debug, " noit_http_request_finalize : match(%d in %d)\n", 
     292  noitL(http_debug, " noit_http_request_finalize : match(%d in %d)\n", 
    287293        (int)(req->current_offset - req->current_input->start), 
    288294        (int)req->current_input->size); 
     
    291297    /* There are left-overs */ 
    292298    int lsize = req->current_input->size - req->current_offset; 
    293     noitL(noit_debug, " noit_http_request_finalize -- leftovers: %d\n", lsize); 
     299    noitL(http_debug, " noit_http_request_finalize -- leftovers: %d\n", lsize); 
    294300    req->first_input = bchain_alloc(lsize); 
    295301    req->first_input->prev = NULL; 
     
    300306           req->current_input->buff + req->current_offset, 
    301307           req->first_input->size); 
     308    req->current_input->size -= lsize; 
    302309    if(req->last_input == req->current_input) 
    303310      req->last_input = req->first_input; 
     
    491498                                   in->allocd - in->size - in->start, 
    492499                                   &mask, ctx->conn.e); 
    493     noitL(noit_debug, " noit_http -> read(%d) = %d\n", ctx->conn.e->fd, len); 
     500    noitL(http_debug, " noit_http -> read(%d) = %d\n", ctx->conn.e->fd, len); 
     501    noitL(http_io, " noit_http:read(%d) => %d [\n%.*s\n]\n", ctx->conn.e->fd, len, len, in->buff + in->start + in->size); 
    494502    if(len == -1 && errno == EAGAIN) return mask; 
    495503    if(len <= 0) goto full_error; 
     
    562570  /* We attempt to consume from the first_input */ 
    563571  struct bchain *in, *tofree; 
    564   noitL(noit_debug, " ... noit_http_session_req_consume(%d) %d of %d\n", 
     572  noitL(http_debug, " ... noit_http_session_req_consume(%d) %d of %d\n", 
    565573        ctx->conn.e->fd, (int)len, 
    566574        (int)(ctx->req.content_length - ctx->req.content_length_read)); 
     
    574582      bytes_read += partial_len; 
    575583      ctx->req.content_length_read += partial_len; 
    576       noitL(noit_debug, " ... filling %d bytes (read through %d/%d)\n", 
     584      noitL(http_debug, " ... filling %d bytes (read through %d/%d)\n", 
    577585            (int)bytes_read, (int)ctx->req.content_length_read, 
    578586            (int)ctx->req.content_length); 
     
    586594        if(in == NULL) { 
    587595          ctx->req.last_input = NULL; 
    588           noitL(noit_debug, " ... noit_http_session_req_consume = %d\n", 
     596          noitL(http_debug, " ... noit_http_session_req_consume = %d\n", 
    589597                (int)bytes_read); 
    590598          return bytes_read; 
     
    607615                                      in->allocd - in->size - in->start, 
    608616                                      mask, ctx->conn.e); 
    609       noitL(noit_debug, " noit_http -> read(%d) = %d\n", ctx->conn.e->fd, rlen); 
     617      noitL(http_debug, " noit_http -> read(%d) = %d\n", ctx->conn.e->fd, rlen); 
     618    noitL(http_io, " noit_http:read(%d) => %d [\n%.*s\n]\n", ctx->conn.e->fd, rlen, rlen, in->buff + in->start + in->size); 
    610619      if(rlen == -1 && errno == EAGAIN) { 
    611620        /* We'd block to read more, but we have data, 
     
    613622        if(ctx->req.first_input->size) break; 
    614623        /* We've got nothing... */ 
    615         noitL(noit_debug, " ... noit_http_session_req_consume = -1 (EAGAIN)\n"); 
     624        noitL(http_debug, " ... noit_http_session_req_consume = -1 (EAGAIN)\n"); 
    616625        return -1; 
    617626      } 
    618627      if(rlen <= 0) { 
    619         noitL(noit_debug, " ... noit_http_session_req_consume = -1 (error)\n"); 
     628        noitL(http_debug, " ... noit_http_session_req_consume = -1 (error)\n"); 
    620629        return -1; 
    621630      } 
     
    641650   * noted that in noit_http_request_release. 
    642651   */ 
    643   noitL(noit_debug, " -> noit_http_session_drive(%d) [%x]\n", e->fd, origmask); 
     652  noitL(http_debug, " -> noit_http_session_drive(%d) [%x]\n", e->fd, origmask); 
    644653  while(ctx->drainage > 0) { 
    645654    int len; 
    646     noitL(noit_debug, "   ... draining last request(%d)\n", e->fd); 
     655    noitL(http_debug, "   ... draining last request(%d)\n", e->fd); 
    647656    len = noit_http_session_req_consume(ctx, NULL, ctx->drainage, &mask); 
    648657    if(len == -1 && errno == EAGAIN) { 
    649       noitL(noit_debug, " <- noit_http_session_drive(%d) [%x]\n", e->fd, mask); 
     658      noitL(http_debug, " <- noit_http_session_drive(%d) [%x]\n", e->fd, mask); 
    650659      return mask; 
    651660    } 
     
    657666  if(ctx->req.complete != noit_true) { 
    658667    int maybe_write_mask; 
    659     noitL(noit_debug, "   -> noit_http_complete_request(%d)\n", e->fd); 
     668    noitL(http_debug, "   -> noit_http_complete_request(%d)\n", e->fd); 
    660669    mask = noit_http_complete_request(ctx, origmask); 
    661     noitL(noit_debug, "   <- noit_http_complete_request(%d) = %d\n", 
     670    noitL(http_debug, "   <- noit_http_complete_request(%d) = %d\n", 
    662671          e->fd, mask); 
    663672    _http_perform_write(ctx, &maybe_write_mask); 
    664673    if(ctx->conn.e == NULL) goto release; 
    665674    if(ctx->req.complete != noit_true) { 
    666       noitL(noit_debug, " <- noit_http_session_drive(%d) [%x]\n", e->fd, 
     675      noitL(http_debug, " <- noit_http_session_drive(%d) [%x]\n", e->fd, 
    667676            mask|maybe_write_mask); 
    668677      return mask | maybe_write_mask; 
    669678    } 
    670     noitL(noit_debug, "HTTP start request (%s)\n", ctx->req.uri_str); 
     679    noitL(http_access, "HTTP start request (%s)\n", ctx->req.uri_str); 
    671680  } 
    672681 
    673682  /* only dispatch if the response is not complete */ 
    674683  if(ctx->res.complete == noit_false) { 
    675     noitL(noit_debug, "   -> dispatch(%d)\n", e->fd); 
     684    noitL(http_debug, "   -> dispatch(%d)\n", e->fd); 
    676685    rv = ctx->dispatcher(ctx); 
    677     noitL(noit_debug, "   <- dispatch(%d) = %d\n", e->fd, rv); 
     686    noitL(http_debug, "   <- dispatch(%d) = %d\n", e->fd, rv); 
    678687  } 
    679688 
     
    693702  if(ctx->req.complete == noit_false) goto next_req; 
    694703  if(ctx->conn.e) { 
    695     noitL(noit_debug, " <- noit_http_session_drive(%d) [%x]\n", e->fd, mask|rv); 
     704    noitL(http_debug, " <- noit_http_session_drive(%d) [%x]\n", e->fd, mask|rv); 
    696705    return mask | rv; 
    697706  } 
    698   noitL(noit_debug, " <- noit_http_session_drive(%d) [%x]\n", e->fd, 0); 
     707  noitL(http_debug, " <- noit_http_session_drive(%d) [%x]\n", e->fd, 0); 
    699708  return 0; 
    700709 release: 
    701710  noit_http_ctx_session_release(ctx); 
    702   noitL(noit_debug, " <- noit_http_session_drive(%d) [%x]\n", e->fd, 0); 
     711  noitL(http_debug, " <- noit_http_session_drive(%d) [%x]\n", e->fd, 0); 
    703712  return 0; 
    704713} 
     
    10341043noit_http_response_end(noit_http_session_ctx *ctx) { 
    10351044  if(ctx->res.output) 
    1036     noitL(noit_debug, "HTTP finished request (%s)\n", ctx->req.uri_str); 
     1045    noitL(http_access, "HTTP finished request (%s)\n", ctx->req.uri_str); 
    10371046  if(!noit_http_response_flush(ctx, noit_true)) return noit_false; 
    10381047  return noit_true; 
     
    10641073} 
    10651074 
     1075void 
     1076noit_http_init() { 
     1077  http_debug = noit_log_stream_find("debug/http"); 
     1078  http_access = noit_log_stream_find("http/access"); 
     1079  http_io = noit_log_stream_find("http/io"); 
     1080} 
  • src/noit_http.h

    rfddf717 rd1eed0a  
    180180  noit_http_response_xml(noit_http_session_ctx *, xmlDocPtr); 
    181181 
     182API_EXPORT(void) 
     183  noit_http_init(); 
    182184 
    183185#endif 
  • src/noit_rest.c

    r3d36f5a rd1eed0a  
    558558} 
    559559void noit_http_rest_init() { 
     560  noit_http_init(); 
    560561  eventer_name_callback("noit_wire_rest_api/1.0", noit_http_rest_handler); 
    561562  eventer_name_callback("http_rest_api", noit_http_rest_raw_handler);