diff options
Diffstat (limited to 'weechat')
-rw-r--r-- | weechat/tomsg.c | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/weechat/tomsg.c b/weechat/tomsg.c index 9d6f65c..c53a9a0 100644 --- a/weechat/tomsg.c +++ b/weechat/tomsg.c @@ -4,6 +4,7 @@ #include <string.h> #include <sys/socket.h> #include <unistd.h> +#include <errno.h> #include <assert.h> #include "weechat-plugin.h" #include "net.h" @@ -213,12 +214,16 @@ static int fd_hook_callback(const void *conn_vp,void *_d,int fd){ conn->linebuf=realloc(conn->linebuf,conn->linebuf_sz); assert(conn->linebuf); } - i64 nr=recv(fd,conn->linebuf+conn->linebuf_len,conn->linebuf_sz-conn->linebuf_len,0); - if(nr<=0){ - fprintf(debugf,"fd_hook_callback: recv() <= 0\n"); - weechat_printf(NULL,"tomsg: Connection dropped"); - weechat_buffer_close(conn->buffer); - return WEECHAT_RC_OK; + i64 nr; + while(true){ + nr=recv(fd,conn->linebuf+conn->linebuf_len,conn->linebuf_sz-conn->linebuf_len,0); + if(nr<=0){ + if(nr<0&&errno==EINTR)continue; + fprintf(debugf,"fd_hook_callback: recv() <= 0: %s\n",strerror(errno)); + weechat_printf(NULL,"tomsg: Connection dropped"); + weechat_buffer_close(conn->buffer); + return WEECHAT_RC_OK; + } } conn->linebuf_len+=nr; while(true){ |