diff options
author | tomsmeding <tom.smeding@gmail.com> | 2017-03-16 22:32:51 +0100 |
---|---|---|
committer | tomsmeding <tom.smeding@gmail.com> | 2017-03-16 22:32:51 +0100 |
commit | 7ad3d4bc79c379f622ea80b1941c787cb2324ba0 (patch) | |
tree | 19d199af98097d0f7b43f9d0c39f303716a96bf1 | |
parent | 9ec8909fef512e71f3a002068cd0635cf959bef2 (diff) |
runloop: fix connection closure handling bug
-rw-r--r-- | runloop.c | 8 |
1 files changed, 6 insertions, 2 deletions
@@ -1,4 +1,5 @@ #include <string.h> +#include <errno.h> #include <sys/select.h> #include "runloop.h" @@ -39,11 +40,14 @@ void runloop_run(void){ if(fd_list[i].fd>maxfd)maxfd=fd_list[i].fd; } int ret=select(maxfd+1,&inset,NULL,NULL,NULL); - if(ret<=0)die_perror("select"); + if(ret<=0){ + if(errno==EINTR)continue; + die_perror("select"); + } for(size_t i=0;i<fd_list_len;i++){ if(FD_ISSET(fd_list[i].fd,&inset)){ if(fd_list[i].func(fd_list[i].fd)){ - memmove(fd_list+i,fd_list+i+1,fd_list_len-i-1); + memmove(fd_list+i,fd_list+i+1,(fd_list_len-i-1)*sizeof(struct fd_list_item)); i--; fd_list_len--; } |