Changeset 885a9d3fca7292fe71341749d026abf2938749c4
- Timestamp:
- 07/02/08 04:42:07
(5 years ago)
- Author:
- Theo Schlossnagle <jesus@omniti.com>
- git-committer:
- Theo Schlossnagle <jesus@omniti.com> 1214973727 +0000
- git-parent:
[fb5f8f9daa6e4df8e9acc3c11501205c21866b72]
- git-author:
- Theo Schlossnagle <jesus@omniti.com> 1214973727 +0000
- Message:
make the jlog sender try harder when sending messages. The SSL write layer can perform partial writes on blocking sockets. closes #41
-
Files:
-
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
| r2bdd297 |
r885a9d3 |
|
| 44 | 44 | } |
|---|
| 45 | 45 | |
|---|
| 46 | | #define Ewrite(a,b) e->opset->write(e->fd, a, b, &mask, e) |
|---|
| | 46 | static int |
|---|
| | 47 | __safe_Ewrite(eventer_t e, void *b, int l, int *mask) { |
|---|
| | 48 | int w, sofar = 0; |
|---|
| | 49 | while(l > sofar) { |
|---|
| | 50 | w = e->opset->write(e->fd, b + sofar, l - sofar, mask, e); |
|---|
| | 51 | if(w <= 0) return w; |
|---|
| | 52 | sofar += w; |
|---|
| | 53 | } |
|---|
| | 54 | return sofar; |
|---|
| | 55 | } |
|---|
| | 56 | #define Ewrite(a,b) __safe_Ewrite(e,a,b,&mask) |
|---|
| | 57 | |
|---|
| 47 | 58 | static int |
|---|
| 48 | 59 | noit_jlog_push(eventer_t e, noit_jlog_closure_t *jcl) { |
|---|
| … | … | |
| 54 | 65 | return -1; |
|---|
| 55 | 66 | while(jcl->count > 0) { |
|---|
| | 67 | int rv; |
|---|
| 56 | 68 | struct { jlog_id chkpt; u_int32_t n_sec, n_usec, n_len; } payload; |
|---|
| 57 | 69 | if(jlog_ctx_read_message(jcl->jlog, &jcl->start, &msg) == -1) |
|---|
| … | … | |
| 64 | 76 | payload.n_usec = htonl(msg.header->tv_usec); |
|---|
| 65 | 77 | payload.n_len = htonl(msg.mess_len); |
|---|
| 66 | | if(Ewrite(&payload, sizeof(payload)) != sizeof(payload)) |
|---|
| | 78 | if((rv = Ewrite(&payload, sizeof(payload))) != sizeof(payload)) { |
|---|
| | 79 | noitL(noit_error, "Error writing jlog header over SSL %d != %d\n", |
|---|
| | 80 | rv, sizeof(payload)); |
|---|
| 67 | 81 | return -1; |
|---|
| 68 | | if(Ewrite(msg.mess, msg.mess_len) != msg.mess_len) |
|---|
| | 82 | } |
|---|
| | 83 | if((rv = Ewrite(msg.mess, msg.mess_len)) != msg.mess_len) { |
|---|
| | 84 | noitL(noit_error, "Error writing jlog message over SSL %d != %d\n", |
|---|
| | 85 | rv, msg.mess_len); |
|---|
| 69 | 86 | return -1; |
|---|
| | 87 | } |
|---|
| 70 | 88 | /* Note what the client must checkpoint */ |
|---|
| 71 | 89 | jcl->chkpt = jcl->start; |
|---|