mirror of
https://github.com/cesanta/mongoose.git
synced 2026-10-17 10:49:47 +00:00
fix mg_send() failing on 0 length
This commit is contained in:
1 parent
b503915ca5
commit
236724ea29
5 files changed
+20
-8
No files matched your search
+3
-3
@@ -2019,9 +2019,9 @@ bool mg_send(struct mg_connection *c, const void *buf, size_t len) {
|
||||
len = trim_len(c, len); // Trimming length if necessary
|
||||
res = udp_send(c, buf, len);
|
||||
} else {
|
||||
res = (bool) mg_iobuf_add(&c->send, c->send.len, buf, len);
|
||||
// res == 0 means an OOM condition (iobuf couldn't resize), yet this is so
|
||||
// far recoverable, let the caller decide
|
||||
res = len == 0 || mg_iobuf_add(&c->send, c->send.len, buf, len) > 0;
|
||||
// returning 0 means an OOM condition (iobuf couldn't resize), yet this is
|
||||
// so far recoverable, let the caller decide
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
+1
-1
@@ -141,7 +141,7 @@ bool mg_send(struct mg_connection *c, const void *buf, size_t len) {
|
||||
iolog(c, (char *) buf, n, false);
|
||||
return n > 0;
|
||||
} else {
|
||||
return (bool) mg_iobuf_add(&c->send, c->send.len, buf, len);
|
||||
return len == 0 || mg_iobuf_add(&c->send, c->send.len, buf, len) > 0;
|
||||
// returning 0 means an OOM condition (iobuf couldn't resize), yet this is
|
||||
// so far recoverable, let the caller decide
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user