mirror of
https://github.com/cesanta/mongoose.git
synced 2026-11-18 19:31:02 +00:00
Merge pull request #2587 from cesanta/tls
Fix #2570: close only when TLS buffers drained
This commit is contained in:
2 files changed
+7
-10
No files matched your search
+3
-5
@@ -7299,15 +7299,13 @@ static void read_conn(struct mg_connection *c) {
|
|||||||
n = recv_raw(c, (char *) &c->rtls.buf[c->rtls.len],
|
n = recv_raw(c, (char *) &c->rtls.buf[c->rtls.len],
|
||||||
c->rtls.size - c->rtls.len);
|
c->rtls.size - c->rtls.len);
|
||||||
// MG_DEBUG(("%lu %ld", c->id, n));
|
// MG_DEBUG(("%lu %ld", c->id, n));
|
||||||
if (n == MG_IO_ERR) {
|
if (n == MG_IO_ERR && mg_tls_pending(c) == 0 && c->rtls.len == 0) {
|
||||||
c->is_closing = 1;
|
c->is_closing = 1;
|
||||||
} else if (n > 0) {
|
} else {
|
||||||
c->rtls.len += (size_t) n;
|
if (n > 0) c->rtls.len += (size_t) n;
|
||||||
if (c->is_tls_hs) mg_tls_handshake(c);
|
if (c->is_tls_hs) mg_tls_handshake(c);
|
||||||
if (c->is_tls_hs) return;
|
if (c->is_tls_hs) return;
|
||||||
n = mg_tls_recv(c, buf, len);
|
n = mg_tls_recv(c, buf, len);
|
||||||
} else if (n == MG_IO_WAIT) {
|
|
||||||
n = mg_tls_recv(c, buf, len);
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
n = recv_raw(c, buf, len);
|
n = recv_raw(c, buf, len);
|
||||||
|
|||||||
+4
-5
@@ -282,15 +282,14 @@ static void read_conn(struct mg_connection *c) {
|
|||||||
n = recv_raw(c, (char *) &c->rtls.buf[c->rtls.len],
|
n = recv_raw(c, (char *) &c->rtls.buf[c->rtls.len],
|
||||||
c->rtls.size - c->rtls.len);
|
c->rtls.size - c->rtls.len);
|
||||||
// MG_DEBUG(("%lu %ld", c->id, n));
|
// MG_DEBUG(("%lu %ld", c->id, n));
|
||||||
if (n == MG_IO_ERR) {
|
if (n == MG_IO_ERR && mg_tls_pending(c) == 0 && c->rtls.len == 0) {
|
||||||
|
// Close only if we have fully drained both raw (rtls) and TLS buffers
|
||||||
c->is_closing = 1;
|
c->is_closing = 1;
|
||||||
} else if (n > 0) {
|
} else {
|
||||||
c->rtls.len += (size_t) n;
|
if (n > 0) c->rtls.len += (size_t) n;
|
||||||
if (c->is_tls_hs) mg_tls_handshake(c);
|
if (c->is_tls_hs) mg_tls_handshake(c);
|
||||||
if (c->is_tls_hs) return;
|
if (c->is_tls_hs) return;
|
||||||
n = mg_tls_recv(c, buf, len);
|
n = mg_tls_recv(c, buf, len);
|
||||||
} else if (n == MG_IO_WAIT) {
|
|
||||||
n = mg_tls_recv(c, buf, len);
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
n = recv_raw(c, buf, len);
|
n = recv_raw(c, buf, len);
|
||||||
|
|||||||
Reference in new issue
Block a user