if(aio->data) {
if(aio->cb.buffer) {
- aio->cb.buffer(mesh, channel, aio->data, aio->len, aio->priv);
+ aio->cb.buffer(mesh, channel, aio->data, aio->done, aio->priv);
}
} else {
if(aio->cb.fd) {
if(aio->data) {
sent = utcp_send(connection, (char *)aio->data + aio->done, todo);
} else {
+ /* Limit the amount we read at once to avoid stack overflows */
+ if(todo > 65536) {
+ todo = 65536;
+ }
+
char buf[todo];
ssize_t result = read(aio->fd, buf, todo);
if(sent != (ssize_t)todo) {
/* We should never get a partial send at this point */
- assert(sent < 0);
+ assert(sent <= 0);
/* Sending failed, abort all outstanding AIO buffers and send a poll callback. */
if(!aio_abort(mesh, channel, &channel->aio_send)) {