wstream: Change wstream_write failure behavior

Before this change, any write that could cause a WStream instance to use more
than `maxmem` would fail, which is not acceptable when writing big chunks of
data. (This could happen when returning contents from a big buffer through the
API, for example).

Writes of any size are now allowed, but before we check if the currently used
memory doesn't break the limit. This should be enough to prevent us from
stacking data when talking to a locked process.
This commit is contained in:
Thiago de Arruda
2014-06-17 10:01:33 -03:00
parent 063d8a5773
commit 0c764fb1a4

View File

@@ -90,7 +90,7 @@ bool wstream_write(WStream *wstream, WBuffer *buffer)
// This should not be called after a wstream was freed
assert(!wstream->freed);
if (wstream->curmem + buffer->size > wstream->maxmem) {
if (wstream->curmem > wstream->maxmem) {
return false;
}