From b2cae6770ba63fedb6059003e9aa0b113060807f Mon Sep 17 00:00:00 2001 From: Tom Smeding Date: Sun, 5 Jul 2020 14:57:13 +0200 Subject: server: Don't crash on ECONNRESET from client --- main.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/main.c b/main.c index b925cd1..145a614 100644 --- a/main.c +++ b/main.c @@ -81,12 +81,12 @@ static bool client_socket_callback(int fd){ ssize_t ret; do ret=read(fd,data->buffer+data->buflen,data->bufsz-data->buflen); while(ret<0&&errno==EINTR); - if(ret<0)die_perror("read"); - if(ret==0){ + if(ret==0||(ret<0&&(errno==ECONNRESET||errno==ETIMEDOUT))){ delete_conn_data(fd); close(fd); return true; } + if(ret<0)die_perror("read"); data->buflen+=ret; while(true){ -- cgit v1.2.3-70-g09d2