Changeset 885a9d3fca7292fe71341749d026abf2938749c4

Show
Ignore:
Timestamp:
07/02/08 04:42:07 (6 years ago)
Author:
Theo Schlossnagle <jesus@omniti.com>
git-committer:
Theo Schlossnagle <jesus@omniti.com> 1214973727 +0000
git-parent:

[fb5f8f9daa6e4df8e9acc3c11501205c21866b72]

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

make the jlog sender try harder when sending messages. The SSL write layer can perform partial writes on blocking sockets. closes #41

Files:

Legend:

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

    r2bdd297 r885a9d3  
    4444} 
    4545 
    46 #define Ewrite(a,b) e->opset->write(e->fd, a, b, &mask, e) 
     46static int 
     47__safe_Ewrite(eventer_t e, void *b, int l, int *mask) { 
     48  int w, sofar = 0; 
     49  while(l > sofar) { 
     50    w = e->opset->write(e->fd, b + sofar, l - sofar, mask, e); 
     51    if(w <= 0) return w; 
     52    sofar += w; 
     53  } 
     54  return sofar; 
     55
     56#define Ewrite(a,b) __safe_Ewrite(e,a,b,&mask) 
     57 
    4758static int 
    4859noit_jlog_push(eventer_t e, noit_jlog_closure_t *jcl) { 
     
    5465    return -1; 
    5566  while(jcl->count > 0) { 
     67    int rv; 
    5668    struct { jlog_id chkpt; u_int32_t n_sec, n_usec, n_len; } payload; 
    5769    if(jlog_ctx_read_message(jcl->jlog, &jcl->start, &msg) == -1) 
     
    6476    payload.n_usec = htonl(msg.header->tv_usec); 
    6577    payload.n_len  = htonl(msg.mess_len); 
    66     if(Ewrite(&payload, sizeof(payload)) != sizeof(payload)) 
     78    if((rv = Ewrite(&payload, sizeof(payload))) != sizeof(payload)) { 
     79      noitL(noit_error, "Error writing jlog header over SSL %d != %d\n", 
     80            rv, sizeof(payload)); 
    6781      return -1; 
    68     if(Ewrite(msg.mess, msg.mess_len) != msg.mess_len) 
     82    } 
     83    if((rv = Ewrite(msg.mess, msg.mess_len)) != msg.mess_len) { 
     84      noitL(noit_error, "Error writing jlog message over SSL %d != %d\n", 
     85            rv, msg.mess_len); 
    6986      return -1; 
     87    } 
    7088    /* Note what the client must checkpoint */ 
    7189    jcl->chkpt = jcl->start;