Immediately close WS connection on error

The implementation was waiting for the client, which leaves some hanging
even after they called close(). This mirrors the behavior for HTTP
connections in client.c where close() is called right before
http_client_free.
master
Jessie Murray 3 years ago
parent d0acdf030e
commit 27ad2413d4
No known key found for this signature in database
GPG Key ID: E7E4D57EDDA744C5

@ -55,7 +55,10 @@ worker_can_read(int fd, short event, void *p) {
if(c->is_websocket) {
/* Got websocket data */
ws_add_data(c);
int add_ret = ws_add_data(c);
if(add_ret == WS_ERROR) {
c->broken = 1; /* likely connection was closed */
}
} else {
/* run parser */
nparsed = http_client_execute(c);
@ -87,6 +90,9 @@ worker_can_read(int fd, short event, void *p) {
}
if(c->broken) { /* terminate client */
if(c->is_websocket) { /* only close for WS since HTTP might use keep-alive */
close(c->fd);
}
http_client_free(c);
} else {
/* start monitoring input again */

Loading…
Cancel
Save