aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortomsmeding <tom.smeding@gmail.com>2017-03-16 22:32:51 +0100
committertomsmeding <tom.smeding@gmail.com>2017-03-16 22:32:51 +0100
commit7ad3d4bc79c379f622ea80b1941c787cb2324ba0 (patch)
tree19d199af98097d0f7b43f9d0c39f303716a96bf1
parent9ec8909fef512e71f3a002068cd0635cf959bef2 (diff)
runloop: fix connection closure handling bug
-rw-r--r--runloop.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/runloop.c b/runloop.c
index d2865a2..30f28b2 100644
--- a/runloop.c
+++ b/runloop.c
@@ -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--;
}