diff options
| -rw-r--r-- | ot_http.c | 7 |
1 files changed, 5 insertions, 2 deletions
| @@ -216,11 +216,14 @@ ssize_t http_sendiovecdata(const int64_t sock, struct ot_workstruct *ws, size_t | |||
| 216 | /* If the current batch's limit is reached, try to reallocate a new batch to work on */ | 216 | /* If the current batch's limit is reached, try to reallocate a new batch to work on */ |
| 217 | if (current->bytesleft > OT_BATCH_LIMIT) { | 217 | if (current->bytesleft > OT_BATCH_LIMIT) { |
| 218 | io_batch *new_batch = realloc(cookie->batch, (cookie->batches + 1) * sizeof(io_batch)); | 218 | io_batch *new_batch = realloc(cookie->batch, (cookie->batches + 1) * sizeof(io_batch)); |
| 219 | |||
| 219 | if (new_batch) { | 220 | if (new_batch) { |
| 220 | cookie->batch = new_batch; | 221 | cookie->batch = new_batch; |
| 221 | if (OT_IOB_INIT(current) != -1) | 222 | if (OT_IOB_INIT(cookie->batch + cookie->batches) != -1) |
| 222 | current = cookie->batch + cookie->batches++; | 223 | ++cookie->batches; |
| 223 | } | 224 | } |
| 225 | /* realloc may have moved the batches, so current is stale either way */ | ||
| 226 | current = cookie->batch + cookie->batches - 1; | ||
| 224 | } | 227 | } |
| 225 | iob_addbuf_free(current, iovector[i].iov_base, iovector[i].iov_len); | 228 | iob_addbuf_free(current, iovector[i].iov_base, iovector[i].iov_len); |
| 226 | } | 229 | } |
