Changeset 4dd8a488802d75bd0661c3e90912b84d7cf3bf7b
- Timestamp:
- 09/25/09 13:44:24
(4 years ago)
- Author:
- Theo Schlossnagle <jesus@omniti.com>
- git-committer:
- Theo Schlossnagle <jesus@omniti.com> 1253886264 +0000
- git-parent:
[643d55510eb48b83ce36de906c7f703b857f07b4]
- git-author:
- Theo Schlossnagle <jesus@omniti.com> 1253886264 +0000
- Message:
Add TCP KEEPALIVE to the outbound jlog connections (fix display errors on the noit statistics due to inplace ntohl() calls. refs #58
-
Files:
-
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
| r7666f79 |
r4dd8a48 |
|
| 301 | 301 | noit_connection_ctx_t *nctx = closure; |
|---|
| 302 | 302 | jlog_streamer_ctx_t *ctx = nctx->consumer_ctx; |
|---|
| | 303 | jlog_streamer_ctx_t dummy; |
|---|
| 303 | 304 | int len; |
|---|
| 304 | 305 | jlog_id n_chkpt; |
|---|
| … | … | |
| 340 | 341 | case JLOG_STREAMER_WANT_COUNT: |
|---|
| 341 | 342 | FULLREAD(e, ctx, sizeof(u_int32_t)); |
|---|
| 342 | | memcpy(&ctx->count, ctx->buffer, sizeof(u_int32_t)); |
|---|
| 343 | | ctx->count = ntohl(ctx->count); |
|---|
| | 343 | memcpy(&dummy.count, ctx->buffer, sizeof(u_int32_t)); |
|---|
| | 344 | ctx->count = ntohl(dummy.count); |
|---|
| 344 | 345 | free(ctx->buffer); ctx->buffer = NULL; |
|---|
| 345 | 346 | ctx->state = JLOG_STREAMER_WANT_HEADER; |
|---|
| … | … | |
| 352 | 353 | } |
|---|
| 353 | 354 | FULLREAD(e, ctx, sizeof(ctx->header)); |
|---|
| 354 | | memcpy(&ctx->header, ctx->buffer, sizeof(ctx->header)); |
|---|
| 355 | | ctx->header.chkpt.log = ntohl(ctx->header.chkpt.log); |
|---|
| 356 | | ctx->header.chkpt.marker = ntohl(ctx->header.chkpt.marker); |
|---|
| 357 | | ctx->header.tv_sec = ntohl(ctx->header.tv_sec); |
|---|
| 358 | | ctx->header.tv_usec = ntohl(ctx->header.tv_usec); |
|---|
| 359 | | ctx->header.message_len = ntohl(ctx->header.message_len); |
|---|
| | 355 | memcpy(&dummy.header, ctx->buffer, sizeof(ctx->header)); |
|---|
| | 356 | ctx->header.chkpt.log = ntohl(dummy.header.chkpt.log); |
|---|
| | 357 | ctx->header.chkpt.marker = ntohl(dummy.header.chkpt.marker); |
|---|
| | 358 | ctx->header.tv_sec = ntohl(dummy.header.tv_sec); |
|---|
| | 359 | ctx->header.tv_usec = ntohl(dummy.header.tv_usec); |
|---|
| | 360 | ctx->header.message_len = ntohl(dummy.header.message_len); |
|---|
| 360 | 361 | free(ctx->buffer); ctx->buffer = NULL; |
|---|
| 361 | 362 | ctx->state = JLOG_STREAMER_WANT_BODY; |
|---|
| … | … | |
| 517 | 518 | eventer_t e; |
|---|
| 518 | 519 | int rv, fd = -1; |
|---|
| | 520 | #ifdef SO_KEEPALIVE |
|---|
| | 521 | int optval; |
|---|
| | 522 | socklen_t optlen = sizeof(optval); |
|---|
| | 523 | #endif |
|---|
| 519 | 524 | |
|---|
| 520 | 525 | if(nctx->wants_permanent_shutdown) { |
|---|
| … | … | |
| 528 | 533 | /* Make it non-blocking */ |
|---|
| 529 | 534 | if(eventer_set_fd_nonblocking(fd)) goto reschedule; |
|---|
| | 535 | #define set_or_bail(type, opt, val) do { \ |
|---|
| | 536 | optval = val; \ |
|---|
| | 537 | optlen = sizeof(optval); \ |
|---|
| | 538 | if(setsockopt(fd, type, opt, &optval, optlen) < 0) { \ |
|---|
| | 539 | noitL(noit_error, "Cannot set " #type "/" #opt " on jlog socket: %s\n", \ |
|---|
| | 540 | strerror(errno)); \ |
|---|
| | 541 | goto reschedule; \ |
|---|
| | 542 | } \ |
|---|
| | 543 | } while(0) |
|---|
| | 544 | #ifdef SO_KEEPALIVE |
|---|
| | 545 | set_or_bail(SOL_SOCKET, SO_KEEPALIVE, 1); |
|---|
| | 546 | #endif |
|---|
| | 547 | #ifdef TCP_KEEPALIVE_THRESHOLD |
|---|
| | 548 | set_or_bail(IPPROTO_TCP, TCP_KEEPALIVE_THRESHOLD, 10 * 1000); |
|---|
| | 549 | #endif |
|---|
| | 550 | #ifdef TCP_KEEPALIVE_ABORT_THRESHOLD |
|---|
| | 551 | set_or_bail(IPPROTO_TCP, TCP_KEEPALIVE_ABORT_THRESHOLD, 30 * 1000); |
|---|
| | 552 | #endif |
|---|
| | 553 | #ifdef TCP_CONN_NOTIFY_THRESHOLD |
|---|
| | 554 | set_or_bail(IPPROTO_TCP, TCP_CONN_NOTIFY_THRESHOLD, 10 * 1000); |
|---|
| | 555 | #endif |
|---|
| | 556 | #ifdef TCP_CONN_ABORT_THRESHOLD |
|---|
| | 557 | set_or_bail(IPPROTO_TCP, TCP_CONN_ABORT_THRESHOLD, 30 * 1000); |
|---|
| | 558 | #endif |
|---|
| 530 | 559 | |
|---|
| 531 | 560 | /* Initiate a connection */ |
|---|