wstream: Make wstream_write consider the return value from uv_write

This commit is contained in:
Thiago de Arruda 2014-06-20 10:52:49 -03:00
parent 30fc6a4fd1
commit c722e22ee6

View File

@ -100,8 +100,7 @@ bool wstream_write(WStream *wstream, WBuffer *buffer)
buffer->refcount++; buffer->refcount++;
if (wstream->curmem > wstream->maxmem) { if (wstream->curmem > wstream->maxmem) {
release_wbuffer(buffer); goto err;
return false;
} }
wstream->curmem += buffer->size; wstream->curmem += buffer->size;
@ -113,9 +112,16 @@ bool wstream_write(WStream *wstream, WBuffer *buffer)
uvbuf.base = buffer->data; uvbuf.base = buffer->data;
uvbuf.len = buffer->size; uvbuf.len = buffer->size;
wstream->pending_reqs++; wstream->pending_reqs++;
uv_write(req, wstream->stream, &uvbuf, 1, write_cb);
if (uv_write(req, wstream->stream, &uvbuf, 1, write_cb)) {
goto err;
}
return true; return true;
err:
release_wbuffer(buffer);
return false;
} }
/// Creates a WBuffer object for holding output data. Instances of this /// Creates a WBuffer object for holding output data. Instances of this