mirror of
https://github.com/cesanta/mongoose.git
synced 2024-11-24 11:09:01 +08:00
Merge pull request #2587 from cesanta/tls
Fix #2570: close only when TLS buffers drained
This commit is contained in:
commit
8dc62c25ed
@ -7299,15 +7299,13 @@ static void read_conn(struct mg_connection *c) {
|
||||
n = recv_raw(c, (char *) &c->rtls.buf[c->rtls.len],
|
||||
c->rtls.size - c->rtls.len);
|
||||
// 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;
|
||||
} else if (n > 0) {
|
||||
c->rtls.len += (size_t) n;
|
||||
} else {
|
||||
if (n > 0) c->rtls.len += (size_t) n;
|
||||
if (c->is_tls_hs) mg_tls_handshake(c);
|
||||
if (c->is_tls_hs) return;
|
||||
n = mg_tls_recv(c, buf, len);
|
||||
} else if (n == MG_IO_WAIT) {
|
||||
n = mg_tls_recv(c, buf, len);
|
||||
}
|
||||
} else {
|
||||
n = recv_raw(c, buf, len);
|
||||
|
@ -282,15 +282,14 @@ static void read_conn(struct mg_connection *c) {
|
||||
n = recv_raw(c, (char *) &c->rtls.buf[c->rtls.len],
|
||||
c->rtls.size - c->rtls.len);
|
||||
// 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;
|
||||
} else if (n > 0) {
|
||||
c->rtls.len += (size_t) n;
|
||||
} else {
|
||||
if (n > 0) c->rtls.len += (size_t) n;
|
||||
if (c->is_tls_hs) mg_tls_handshake(c);
|
||||
if (c->is_tls_hs) return;
|
||||
n = mg_tls_recv(c, buf, len);
|
||||
} else if (n == MG_IO_WAIT) {
|
||||
n = mg_tls_recv(c, buf, len);
|
||||
}
|
||||
} else {
|
||||
n = recv_raw(c, buf, len);
|
||||
|
Loading…
Reference in New Issue
Block a user