File tree Expand file tree Collapse file tree 4 files changed +16
-6
lines changed Expand file tree Collapse file tree 4 files changed +16
-6
lines changed Original file line number Diff line number Diff line change @@ -7529,9 +7529,13 @@ static void read_conn(struct mg_connection *c) {
7529
7529
if (!ioalloc(c, &c->rtls)) return;
7530
7530
n = recv_raw(c, (char *) &c->rtls.buf[c->rtls.len],
7531
7531
c->rtls.size - c->rtls.len);
7532
- if (n == MG_IO_ERR && mg_tls_pending(c) == 0) {
7533
- // Close only if we have fully drained both raw (rtls) and TLS buffers
7534
- c->is_closing = 1;
7532
+ if (n == MG_IO_ERR) {
7533
+ if (c->rtls.len == 0 || c->is_io_err) {
7534
+ // Close only when we have fully drained both rtls and TLS buffers
7535
+ c->is_closing = 1; // or there's nothing we can do about it.
7536
+ } else { // TLS buffer is capped to max record size, mark and
7537
+ c->is_io_err = 1; // give TLS a chance to process that.
7538
+ }
7535
7539
} else {
7536
7540
if (n > 0) c->rtls.len += (size_t) n;
7537
7541
if (c->is_tls_hs) mg_tls_handshake(c);
Original file line number Diff line number Diff line change @@ -2157,6 +2157,7 @@ struct mg_connection {
2157
2157
unsigned is_resp : 1 ; // Response is still being generated
2158
2158
unsigned is_readable : 1 ; // Connection is ready to read
2159
2159
unsigned is_writable : 1 ; // Connection is ready to write
2160
+ unsigned is_io_err : 1 ; // Remember IO_ERR condition for later use
2160
2161
};
2161
2162
2162
2163
void mg_mgr_poll (struct mg_mgr *, int ms);
Original file line number Diff line number Diff line change @@ -76,6 +76,7 @@ struct mg_connection {
76
76
unsigned is_resp : 1 ; // Response is still being generated
77
77
unsigned is_readable : 1 ; // Connection is ready to read
78
78
unsigned is_writable : 1 ; // Connection is ready to write
79
+ unsigned is_io_err : 1 ; // Remember IO_ERR condition for later use
79
80
};
80
81
81
82
void mg_mgr_poll (struct mg_mgr * , int ms );
Original file line number Diff line number Diff line change @@ -282,9 +282,13 @@ static void read_conn(struct mg_connection *c) {
282
282
if (!ioalloc (c , & c -> rtls )) return ;
283
283
n = recv_raw (c , (char * ) & c -> rtls .buf [c -> rtls .len ],
284
284
c -> rtls .size - c -> rtls .len );
285
- if (n == MG_IO_ERR && mg_tls_pending (c ) == 0 ) {
286
- // Close only if we have fully drained both raw (rtls) and TLS buffers
287
- c -> is_closing = 1 ;
285
+ if (n == MG_IO_ERR ) {
286
+ if (c -> rtls .len == 0 || c -> is_io_err ) {
287
+ // Close only when we have fully drained both rtls and TLS buffers
288
+ c -> is_closing = 1 ; // or there's nothing we can do about it.
289
+ } else { // TLS buffer is capped to max record size, mark and
290
+ c -> is_io_err = 1 ; // give TLS a chance to process that.
291
+ }
288
292
} else {
289
293
if (n > 0 ) c -> rtls .len += (size_t ) n ;
290
294
if (c -> is_tls_hs ) mg_tls_handshake (c );
You can’t perform that action at this time.
0 commit comments