Show
Ignore:
Timestamp:
08/13/08 21:36:52 (6 years ago)
Author:
Theo Schlossnagle <jesus@omniti.com>
git-committer:
Theo Schlossnagle <jesus@omniti.com> 1218663412 +0000
git-parent:

[222a9737db8ea7fefdf3ee212cae3e505459add2]

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

closes #52. flag-day(noitd,stratcond)

Files:

Legend:

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

    rfb5f8f9 r6bb9ef8  
    4545 
    4646  enum { 
    47     WANT_COUNT = 0, 
    48     WANT_HEADER = 1, 
    49     WANT_BODY = 2, 
    50     WANT_CHKPT = 3, 
     47    WANT_INITIATE = 0, 
     48    WANT_COUNT = 1, 
     49    WANT_HEADER = 2, 
     50    WANT_BODY = 3, 
     51    WANT_CHKPT = 4, 
    5152  } state; 
    5253  int count;            /* Number of jlog messages we need to read */ 
     
    180181stratcon_jlog_recv_handler(eventer_t e, int mask, void *closure, 
    181182                           struct timeval *now) { 
     183  static u_int32_t jlog_feed_cmd = 0; 
    182184  jlog_streamer_ctx_t *ctx = closure; 
    183185  int len; 
    184186  jlog_id n_chkpt; 
    185187 
     188  if(!jlog_feed_cmd) jlog_feed_cmd = htonl(NOIT_JLOG_DATA_FEED); 
     189 
    186190  if(mask & EVENTER_EXCEPTION || ctx->wants_shutdown) { 
    187191 socket_error: 
    188     ctx->state = WANT_COUNT
     192    ctx->state = WANT_INITIATE
    189193    ctx->count = 0; 
    190194    ctx->bytes_read = 0; 
     
    200204  while(1) { 
    201205    switch(ctx->state) { 
     206      case WANT_INITIATE: 
     207        len = e->opset->write(e->fd, &jlog_feed_cmd, sizeof(&jlog_feed_cmd), 
     208                              &mask, e); 
     209        if(len < 0) { 
     210          if(errno == EAGAIN) return mask | EVENTER_EXCEPTION; 
     211          goto socket_error; 
     212        } 
     213        if(len != sizeof(jlog_feed_cmd)) { 
     214          noitL(noit_error, "short write on initiating stream.\n"); 
     215          goto socket_error; 
     216        } 
     217        ctx->state = WANT_COUNT; 
     218        break; 
     219 
    202220      case WANT_COUNT: 
    203221        FULLREAD(e, ctx, sizeof(u_int32_t));