Changeset 1da42f7ee53fe062b95962b97d885d16c7363589

Show
Ignore:
Timestamp:
10/26/09 19:38:54 (4 years ago)
Author:
Theo Schlossnagle <jesus@omniti.com>
git-committer:
Theo Schlossnagle <jesus@omniti.com> 1256585934 +0000
git-parent:

[c40e534ab56b44d80356a1b490d260db862e2dc4]

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

fixes #202 flag-day(noitd,stratcond)

Files:

Legend:

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

    rb7ab38b r1da42f7  
    208208  acceptor_closure_t *ac = closure; 
    209209  noit_jlog_closure_t *jcl = ac->service_ctx; 
     210  char errbuff[256]; 
     211  const char *errstr = "unknown error"; 
    210212 
    211213  if(mask & EVENTER_EXCEPTION || (jcl && jcl->wants_shutdown)) { 
     214    int len, nlen; 
    212215socket_error: 
    213216    /* Exceptions cause us to simply snip the connection */ 
     217    len = strlen(errstr); 
     218    nlen = htonl(0 - len); 
     219    e->opset->write(e->fd, &nlen, sizeof(nlen), &newmask, e); 
     220    e->opset->write(e->fd, errstr, strlen(errstr), &newmask, e); 
    214221    eventer_remove_fd(e->fd); 
    215222    e->opset->close(e->fd, &newmask, e); 
     
    228235                           strlen("log_transit_feed_name"), 
    229236                           &logname)) { 
    230       noitL(noit_error, "No 'log_transit_feed_name' specified in log_transit.\n"); 
     237      errstr = "No 'log_transit_feed_name' specified in log_transit."; 
     238      noitL(noit_error, "%s\n", errstr); 
    231239      goto socket_error; 
    232240    } 
    233241    ls = noit_log_stream_find(logname); 
    234242    if(!ls) { 
    235       noitL(noit_error, "Could not find log '%s' for log_transit.\n", 
    236             logname); 
     243      snprintf(errbuff, sizeof(errbuff), 
     244               "Could not find log '%s' for log_transit.", logname); 
     245      errstr = errbuff; 
     246      noitL(noit_error, "%s\n", errstr); 
    237247      goto socket_error; 
    238248    } 
    239249    if(!ls->type || strcmp(ls->type, "jlog")) { 
    240       noitL(noit_error, "Log '%s' for log_transit is not a jlog.\n", 
    241             logname); 
     250      snprintf(errbuff, sizeof(errbuff), 
     251               "Log '%s' for log_transit is not a jlog.", logname); 
     252      errstr = errbuff; 
     253      noitL(noit_error, "%s\n", errstr); 
    242254      goto socket_error; 
    243255    } 
    244256    if(ac->cmd == NOIT_JLOG_DATA_FEED) { 
    245257      if(!ac->remote_cn) { 
    246         noitL(noit_error, "jlog transit started to unidentified party.\n"); 
     258        errstr = "jlog transit started to unidentified party."; 
     259        noitL(noit_error, "%s\n", errstr); 
    247260        goto socket_error; 
    248261      } 
     
    268281    jcl->jlog = jlog_new(path); 
    269282    if(ac->cmd == NOIT_JLOG_DATA_TEMP_FEED) 
    270       if(jlog_ctx_add_subscriber(jcl->jlog, jcl->subscriber, JLOG_END) == -1) 
    271         noitL(noit_error, "jlog reader[%s] error: %s\n", jcl->subscriber, 
    272               jlog_ctx_err_string(jcl->jlog)); 
     283      if(jlog_ctx_add_subscriber(jcl->jlog, jcl->subscriber, JLOG_END) == -1) { 
     284        snprintf(errbuff, sizeof(errbuff), 
     285                 "jlog reader[%s] error: %s", jcl->subscriber, 
     286                 jlog_ctx_err_string(jcl->jlog)); 
     287        errstr = errbuff; 
     288        noitL(noit_error, "%s\n", errstr); 
     289      } 
    273290    if(jlog_ctx_open_reader(jcl->jlog, jcl->subscriber) == -1) { 
    274       noitL(noit_error, "jlog reader[%s] error: %s\n", jcl->subscriber, 
    275             jlog_ctx_err_string(jcl->jlog)); 
     291      snprintf(errbuff, sizeof(errbuff), 
     292               "jlog reader[%s] error: %s", jcl->subscriber, 
     293               jlog_ctx_err_string(jcl->jlog)); 
     294      errstr = errbuff; 
     295      noitL(noit_error, "%s\n", errstr); 
    276296      goto socket_error; 
    277297    } 
  • src/stratcon_jlog_streamer.c

    r06c1b70 r1da42f7  
    112112        case JLOG_STREAMER_WANT_INITIATE: state = "initiate"; break; 
    113113        case JLOG_STREAMER_WANT_COUNT: state = "waiting for next batch"; break; 
     114        case JLOG_STREAMER_WANT_ERROR: state = "waiting for error"; break; 
    114115        case JLOG_STREAMER_WANT_HEADER: state = "reading header"; break; 
    115116        case JLOG_STREAMER_WANT_BODY: state = "reading body"; break; 
     
    344345        break; 
    345346 
     347      case JLOG_STREAMER_WANT_ERROR: 
     348        FULLREAD(e, ctx, 0 - ctx->count); 
     349        noitL(noit_error, "[%s] %.*s\n", nctx->remote_str, 
     350              0 - ctx->count, ctx->buffer); 
     351        free(ctx->buffer); ctx->buffer = NULL; 
     352        goto socket_error; 
     353        break; 
     354 
    346355      case JLOG_STREAMER_WANT_COUNT: 
    347356        FULLREAD(e, ctx, sizeof(u_int32_t)); 
     
    349358        ctx->count = ntohl(dummy.count); 
    350359        free(ctx->buffer); ctx->buffer = NULL; 
    351         ctx->state = JLOG_STREAMER_WANT_HEADER; 
     360        if(ctx->count < 0) 
     361          ctx->state = JLOG_STREAMER_WANT_ERROR; 
     362        else 
     363          ctx->state = JLOG_STREAMER_WANT_HEADER; 
    352364        break; 
    353365 
     
    811823        case JLOG_STREAMER_WANT_INITIATE: state = "initiate"; break; 
    812824        case JLOG_STREAMER_WANT_COUNT: state = "waiting for next batch"; break; 
     825        case JLOG_STREAMER_WANT_ERROR: state = "waiting for error"; break; 
    813826        case JLOG_STREAMER_WANT_HEADER: state = "reading header"; break; 
    814827        case JLOG_STREAMER_WANT_BODY: state = "reading body"; break; 
  • src/stratcon_jlog_streamer.h

    r5360a1e r1da42f7  
    7979    JLOG_STREAMER_IS_ASYNC = 4, 
    8080    JLOG_STREAMER_WANT_CHKPT = 5, 
     81    JLOG_STREAMER_WANT_ERROR = 6, 
    8182  } state; 
    8283  int count;            /* Number of jlog messages we need to read */