aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Smeding <tom.smeding@gmail.com>2020-07-05 14:57:13 +0200
committerTom Smeding <tom.smeding@gmail.com>2020-07-05 14:57:13 +0200
commitb2cae6770ba63fedb6059003e9aa0b113060807f (patch)
tree7c6f771bd69cb63b55e172d82975af70b13e2f46
parentd43184f306eb1406f6cad5348d0138f6bec276dd (diff)
server: Don't crash on ECONNRESET from client
-rw-r--r--main.c4
1 files 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){