Changeset 1da42f7ee53fe062b95962b97d885d16c7363589
- 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
| rb7ab38b |
r1da42f7 |
|
| 208 | 208 | acceptor_closure_t *ac = closure; |
|---|
| 209 | 209 | noit_jlog_closure_t *jcl = ac->service_ctx; |
|---|
| | 210 | char errbuff[256]; |
|---|
| | 211 | const char *errstr = "unknown error"; |
|---|
| 210 | 212 | |
|---|
| 211 | 213 | if(mask & EVENTER_EXCEPTION || (jcl && jcl->wants_shutdown)) { |
|---|
| | 214 | int len, nlen; |
|---|
| 212 | 215 | socket_error: |
|---|
| 213 | 216 | /* 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); |
|---|
| 214 | 221 | eventer_remove_fd(e->fd); |
|---|
| 215 | 222 | e->opset->close(e->fd, &newmask, e); |
|---|
| … | … | |
| 228 | 235 | strlen("log_transit_feed_name"), |
|---|
| 229 | 236 | &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); |
|---|
| 231 | 239 | goto socket_error; |
|---|
| 232 | 240 | } |
|---|
| 233 | 241 | ls = noit_log_stream_find(logname); |
|---|
| 234 | 242 | 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); |
|---|
| 237 | 247 | goto socket_error; |
|---|
| 238 | 248 | } |
|---|
| 239 | 249 | 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); |
|---|
| 242 | 254 | goto socket_error; |
|---|
| 243 | 255 | } |
|---|
| 244 | 256 | if(ac->cmd == NOIT_JLOG_DATA_FEED) { |
|---|
| 245 | 257 | 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); |
|---|
| 247 | 260 | goto socket_error; |
|---|
| 248 | 261 | } |
|---|
| … | … | |
| 268 | 281 | jcl->jlog = jlog_new(path); |
|---|
| 269 | 282 | 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 | } |
|---|
| 273 | 290 | 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); |
|---|
| 276 | 296 | goto socket_error; |
|---|
| 277 | 297 | } |
|---|
| r06c1b70 |
r1da42f7 |
|
| 112 | 112 | case JLOG_STREAMER_WANT_INITIATE: state = "initiate"; break; |
|---|
| 113 | 113 | case JLOG_STREAMER_WANT_COUNT: state = "waiting for next batch"; break; |
|---|
| | 114 | case JLOG_STREAMER_WANT_ERROR: state = "waiting for error"; break; |
|---|
| 114 | 115 | case JLOG_STREAMER_WANT_HEADER: state = "reading header"; break; |
|---|
| 115 | 116 | case JLOG_STREAMER_WANT_BODY: state = "reading body"; break; |
|---|
| … | … | |
| 344 | 345 | break; |
|---|
| 345 | 346 | |
|---|
| | 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 | |
|---|
| 346 | 355 | case JLOG_STREAMER_WANT_COUNT: |
|---|
| 347 | 356 | FULLREAD(e, ctx, sizeof(u_int32_t)); |
|---|
| … | … | |
| 349 | 358 | ctx->count = ntohl(dummy.count); |
|---|
| 350 | 359 | 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; |
|---|
| 352 | 364 | break; |
|---|
| 353 | 365 | |
|---|
| … | … | |
| 811 | 823 | case JLOG_STREAMER_WANT_INITIATE: state = "initiate"; break; |
|---|
| 812 | 824 | case JLOG_STREAMER_WANT_COUNT: state = "waiting for next batch"; break; |
|---|
| | 825 | case JLOG_STREAMER_WANT_ERROR: state = "waiting for error"; break; |
|---|
| 813 | 826 | case JLOG_STREAMER_WANT_HEADER: state = "reading header"; break; |
|---|
| 814 | 827 | case JLOG_STREAMER_WANT_BODY: state = "reading body"; break; |
|---|
| r5360a1e |
r1da42f7 |
|
| 79 | 79 | JLOG_STREAMER_IS_ASYNC = 4, |
|---|
| 80 | 80 | JLOG_STREAMER_WANT_CHKPT = 5, |
|---|
| | 81 | JLOG_STREAMER_WANT_ERROR = 6, |
|---|
| 81 | 82 | } state; |
|---|
| 82 | 83 | int count; /* Number of jlog messages we need to read */ |
|---|