Changeset 1cd669dc031d6aa16971e3895924d5507e3b76bd

Show
Ignore:
Timestamp:
05/13/09 21:08:11 (5 years ago)
Author:
Theo Schlossnagle <jesus@omniti.com>
git-committer:
Theo Schlossnagle <jesus@omniti.com> 1242248891 +0000
git-parent:

[2fcc420e35326442e9fb1ab8bacf4d7259e2a6fe]

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

fixes #127

Files:

Legend:

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

    ra907717 r1cd669d  
    175175      noitL(noit_error, "socket error: %s\n", strerror(errno)); 
    176176 socket_error: 
    177     ctx->state = WANT_INITIATE; 
     177    ctx->state = JLOG_STREAMER_WANT_INITIATE; 
    178178    ctx->count = 0; 
    179179    ctx->bytes_read = 0; 
     
    189189  while(1) { 
    190190    switch(ctx->state) { 
    191       case WANT_INITIATE: 
     191      case JLOG_STREAMER_WANT_INITIATE: 
    192192        len = e->opset->write(e->fd, &ctx->jlog_feed_cmd, 
    193193                              sizeof(&ctx->jlog_feed_cmd), 
     
    201201          goto socket_error; 
    202202        } 
    203         ctx->state = WANT_COUNT; 
     203        ctx->state = JLOG_STREAMER_WANT_COUNT; 
    204204        break; 
    205205 
    206       case WANT_COUNT: 
     206      case JLOG_STREAMER_WANT_COUNT: 
    207207        FULLREAD(e, ctx, sizeof(u_int32_t)); 
    208208        memcpy(&ctx->count, ctx->buffer, sizeof(u_int32_t)); 
    209209        ctx->count = ntohl(ctx->count); 
    210210        free(ctx->buffer); ctx->buffer = NULL; 
    211         ctx->state = WANT_HEADER; 
     211        ctx->state = JLOG_STREAMER_WANT_HEADER; 
    212212        break; 
    213213 
    214       case WANT_HEADER: 
     214      case JLOG_STREAMER_WANT_HEADER: 
    215215        if(ctx->count == 0) { 
    216           ctx->state = WANT_COUNT; 
     216          ctx->state = JLOG_STREAMER_WANT_COUNT; 
    217217          break; 
    218218        } 
     
    225225        ctx->header.message_len = ntohl(ctx->header.message_len); 
    226226        free(ctx->buffer); ctx->buffer = NULL; 
    227         ctx->state = WANT_BODY; 
     227        ctx->state = JLOG_STREAMER_WANT_BODY; 
    228228        break; 
    229229 
    230       case WANT_BODY: 
     230      case JLOG_STREAMER_WANT_BODY: 
    231231        FULLREAD(e, ctx, (unsigned long)ctx->header.message_len); 
    232232        ctx->push(DS_OP_INSERT, &nctx->r.remote, ctx->buffer); 
     
    240240          memcpy(completion_e, e, sizeof(*e)); 
    241241          completion_e->mask = EVENTER_WRITE | EVENTER_EXCEPTION; 
    242           ctx->state = WANT_CHKPT; 
     242          ctx->state = JLOG_STREAMER_WANT_CHKPT; 
    243243          ctx->push(DS_OP_CHKPT, &nctx->r.remote, completion_e); 
    244244          noitL(noit_debug, "Pushing batch asynch...\n"); 
    245245          return 0; 
    246246        } else 
    247           ctx->state = WANT_HEADER; 
     247          ctx->state = JLOG_STREAMER_WANT_HEADER; 
    248248        break; 
    249249 
    250       case WANT_CHKPT: 
     250      case JLOG_STREAMER_WANT_CHKPT: 
    251251        noitL(noit_debug, "Pushing checkpoint: [%u/%u]\n", 
    252252              ctx->header.chkpt.log, ctx->header.chkpt.marker); 
     
    265265          goto socket_error; 
    266266        } 
    267         ctx->state = WANT_COUNT; 
     267        ctx->state = JLOG_STREAMER_WANT_COUNT; 
    268268        break; 
    269269    } 
  • src/stratcon_jlog_streamer.h

    ra907717 r1cd669d  
    4141 
    4242  enum { 
    43     WANT_INITIATE = 0, 
    44     WANT_COUNT = 1, 
    45     WANT_HEADER = 2, 
    46     WANT_BODY = 3, 
    47     WANT_CHKPT = 4, 
     43    JLOG_STREAMER_WANT_INITIATE = 0, 
     44    JLOG_STREAMER_WANT_COUNT = 1, 
     45    JLOG_STREAMER_WANT_HEADER = 2, 
     46    JLOG_STREAMER_WANT_BODY = 3, 
     47    JLOG_STREAMER_WANT_CHKPT = 4, 
    4848  } state; 
    4949  int count;            /* Number of jlog messages we need to read */ 
  • src/stratcon_realtime_http.c

    r6210da7 r1cd669d  
    3939 
    4040  enum { 
    41     WANT_INITIATE = 0, 
    42     WANT_SEND_INTERVAL = 1, 
    43     WANT_SEND_UUID = 2, 
    44     WANT_HEADER = 3, 
    45     WANT_BODY = 4, 
     41    REALTIME_HTTP_WANT_INITIATE = 0, 
     42    REALTIME_HTTP_WANT_SEND_INTERVAL = 1, 
     43    REALTIME_HTTP_WANT_SEND_UUID = 2, 
     44    REALTIME_HTTP_WANT_HEADER = 3, 
     45    REALTIME_HTTP_WANT_BODY = 4, 
    4646  } state; 
    4747  int count;            /* Number of jlog messages we need to read */ 
     
    249249  if(mask & EVENTER_EXCEPTION || nctx->wants_shutdown) { 
    250250 socket_error: 
    251     ctx->state = WANT_INITIATE; 
     251    ctx->state = REALTIME_HTTP_WANT_INITIATE; 
    252252    ctx->count = 0; 
    253253    ctx->bytes_read = 0; 
     
    289289 
    290290    switch(ctx->state) { 
    291       case WANT_INITIATE: 
     291      case REALTIME_HTTP_WANT_INITIATE: 
    292292        full_nb_write(&livestream_cmd, sizeof(livestream_cmd)); 
    293         ctx->state = WANT_SEND_INTERVAL; 
    294       case WANT_SEND_INTERVAL: 
     293        ctx->state = REALTIME_HTTP_WANT_SEND_INTERVAL; 
     294      case REALTIME_HTTP_WANT_SEND_INTERVAL: 
    295295        nint = htonl(ctx->rt->interval); 
    296296        full_nb_write(&nint, sizeof(nint)); 
    297         ctx->state = WANT_SEND_UUID; 
    298       case WANT_SEND_UUID: 
     297        ctx->state = REALTIME_HTTP_WANT_SEND_UUID; 
     298      case REALTIME_HTTP_WANT_SEND_UUID: 
    299299        uuid_unparse_lower(ctx->rt->checkid, uuid_str); 
    300300        full_nb_write(uuid_str, 36); 
    301         ctx->state = WANT_HEADER; 
    302       case WANT_HEADER: 
     301        ctx->state = REALTIME_HTTP_WANT_HEADER; 
     302      case REALTIME_HTTP_WANT_HEADER: 
    303303        FULLREAD(e, ctx, sizeof(u_int32_t)); 
    304304        memcpy(&net_body_len, ctx->buffer, sizeof(u_int32_t)); 
    305305        ctx->body_len = ntohl(net_body_len); 
    306306        free(ctx->buffer); ctx->buffer = NULL; 
    307         ctx->state = WANT_BODY; 
     307        ctx->state = REALTIME_HTTP_WANT_BODY; 
    308308        break; 
    309       case WANT_BODY: 
     309      case REALTIME_HTTP_WANT_BODY: 
    310310        FULLREAD(e, ctx, ctx->body_len); 
    311311        if(stratcon_line_to_javascript(ctx->ctx, ctx->buffer)) goto socket_error; 
    312312        free(ctx->buffer); ctx->buffer = NULL; 
    313         ctx->state = WANT_HEADER; 
     313        ctx->state = REALTIME_HTTP_WANT_HEADER; 
    314314        break; 
    315315    }