Changeset be05f9f62e0da14f7ee9e4be1482b2698b400ac4
- Timestamp:
- 01/26/09 00:34:35
(4 years ago)
- Author:
- Theo Schlossnagle <jesus@omniti.com>
- git-committer:
- Theo Schlossnagle <jesus@omniti.com> 1232930075 +0000
- git-parent:
[c7df82abd064c1843945283eceffb7eb63a27dcd]
- git-author:
- Theo Schlossnagle <jesus@omniti.com> 1232930075 +0000
- Message:
make http flush fail when things go south, refs #71
-
Files:
-
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
| r2d89607 |
rbe05f9f |
|
| 188 | 188 | noit_http_request_finalize(noit_http_request *req, noit_boolean *err) { |
|---|
| 189 | 189 | int start; |
|---|
| 190 | | const char *mstr, *last_name; |
|---|
| | 190 | const char *mstr, *last_name = NULL; |
|---|
| 191 | 191 | struct bchain *b; |
|---|
| 192 | 192 | |
|---|
| … | … | |
| 725 | 725 | eventer_update(ctx->conn.e, mask); |
|---|
| 726 | 726 | } |
|---|
| 727 | | return noit_true; |
|---|
| | 727 | /* If the write fails completely, the event will be closed, freed and NULL */ |
|---|
| | 728 | return ctx->conn.e ? noit_true : noit_false; |
|---|
| 728 | 729 | } |
|---|
| 729 | 730 | noit_boolean |
|---|
| r2d89607 |
rbe05f9f |
|
| 77 | 77 | int len; |
|---|
| 78 | 78 | |
|---|
| | 79 | #define BAIL_HTTP_WRITE do { \ |
|---|
| | 80 | noitL(noit_error, "javascript emit failed: %s:%s:%d\n", \ |
|---|
| | 81 | __FILE__, __FUNCTION__, __LINE__); \ |
|---|
| | 82 | return -1; \ |
|---|
| | 83 | } while(0) |
|---|
| | 84 | |
|---|
| 79 | 85 | #define PROCESS_NEXT_FIELD(t,l) do { \ |
|---|
| 80 | 86 | if(!*scp) goto bad_row; \ |
|---|
| … | … | |
| 99 | 105 | if(buff[0] == 'M') { |
|---|
| 100 | 106 | snprintf(buffer, sizeof(buffer), "<script>window.parent.plot_iframe_data('"); |
|---|
| 101 | | if(noit_http_response_append(ctx, buffer, strlen(buffer)) == noit_false) return -1; |
|---|
| | 107 | if(noit_http_response_append(ctx, buffer, strlen(buffer)) == noit_false) BAIL_HTTP_WRITE; |
|---|
| 102 | 108 | |
|---|
| 103 | 109 | /* Time */ |
|---|
| 104 | 110 | PROCESS_NEXT_FIELD(token,len); |
|---|
| 105 | | if(noit_http_response_append(ctx, token, len) == noit_false) return -1; |
|---|
| | 111 | if(noit_http_response_append(ctx, token, len) == noit_false) BAIL_HTTP_WRITE; |
|---|
| 106 | 112 | |
|---|
| 107 | 113 | snprintf(buffer, sizeof(buffer), "', '"); |
|---|
| 108 | | if(noit_http_response_append(ctx, buffer, strlen(buffer)) == noit_false) return -1; |
|---|
| | 114 | if(noit_http_response_append(ctx, buffer, strlen(buffer)) == noit_false) BAIL_HTTP_WRITE; |
|---|
| 109 | 115 | |
|---|
| 110 | 116 | /* UUID */ |
|---|
| 111 | 117 | PROCESS_NEXT_FIELD(token,len); |
|---|
| 112 | | if(noit_http_response_append(ctx, token, len) == noit_false) return -1; |
|---|
| | 118 | if(noit_http_response_append(ctx, token, len) == noit_false) BAIL_HTTP_WRITE; |
|---|
| 113 | 119 | |
|---|
| 114 | 120 | snprintf(buffer, sizeof(buffer), "', '"); |
|---|
| 115 | | if(noit_http_response_append(ctx, buffer, strlen(buffer)) == noit_false) return -1; |
|---|
| | 121 | if(noit_http_response_append(ctx, buffer, strlen(buffer)) == noit_false) BAIL_HTTP_WRITE; |
|---|
| 116 | 122 | |
|---|
| 117 | 123 | /* name */ |
|---|
| 118 | 124 | PROCESS_NEXT_FIELD(token,len); |
|---|
| 119 | | if(noit_http_response_append(ctx, token, len) == noit_false) return -1; |
|---|
| | 125 | if(noit_http_response_append(ctx, token, len) == noit_false) BAIL_HTTP_WRITE; |
|---|
| 120 | 126 | |
|---|
| 121 | 127 | snprintf(buffer, sizeof(buffer), "', '"); |
|---|
| 122 | | if(noit_http_response_append(ctx, buffer, strlen(buffer)) == noit_false) return -1; |
|---|
| | 128 | if(noit_http_response_append(ctx, buffer, strlen(buffer)) == noit_false) BAIL_HTTP_WRITE; |
|---|
| 123 | 129 | |
|---|
| 124 | 130 | PROCESS_NEXT_FIELD(token,len); /* skip type */ |
|---|
| 125 | 131 | PROCESS_LAST_FIELD(token,len); /* value */ |
|---|
| 126 | | if(noit_http_response_append(ctx, token, len) == noit_false) return -1; |
|---|
| | 132 | if(noit_http_response_append(ctx, token, len) == noit_false) BAIL_HTTP_WRITE; |
|---|
| 127 | 133 | |
|---|
| 128 | 134 | snprintf(buffer, sizeof(buffer), "');</script>\n"); |
|---|
| 129 | | if(noit_http_response_append(ctx, buffer, strlen(buffer)) == noit_false) return -1; |
|---|
| 130 | | |
|---|
| 131 | | if(noit_http_response_flush(ctx, noit_false) == noit_false) return -1; |
|---|
| | 135 | if(noit_http_response_append(ctx, buffer, strlen(buffer)) == noit_false) BAIL_HTTP_WRITE; |
|---|
| | 136 | |
|---|
| | 137 | if(noit_http_response_flush(ctx, noit_false) == noit_false) BAIL_HTTP_WRITE; |
|---|
| 132 | 138 | } |
|---|
| 133 | 139 | |
|---|
| … | … | |
| 135 | 141 | |
|---|
| 136 | 142 | bad_row: |
|---|
| 137 | | return -1; |
|---|
| | 143 | BAIL_HTTP_WRITE; |
|---|
| 138 | 144 | if(0) { |
|---|
| 139 | 145 | noit_http_response_end(ctx); |
|---|