From 57b66cfd6ad5f5504bab2bade4e031cc851498b4 Mon Sep 17 00:00:00 2001 From: epochqwert Date: Fri, 3 Jun 2016 06:33:45 +0000 Subject: added a more descriptive recv error message. --- libirc.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/libirc.c b/libirc.c index 84fe37b..6589ff0 100644 --- a/libirc.c +++ b/libirc.c @@ -121,6 +121,7 @@ int runem(int *fds,void (*line_handler)(),void (*extra_handler)()) { fd_set readfs; struct timeval timeout; int fdmax=0,n,i; + char tmp[256]; char *backlogs[fdl]; char *t,*line=0; int blsize[fdl]; @@ -151,7 +152,11 @@ int runem(int *fds,void (*line_handler)(),void (*extra_handler)()) { if(j == 0) continue;//don't bother to loop over them. for(i=0;fds[i] != -1;i++) { if(!FD_ISSET(fds[i],&readfs)) continue; - if((n=recv(fds[i],buffers[i],CHUNK,0)) <= 0) return (perror("recv"),2); + if((n=recv(fds[i],buffers[i],CHUNK,0)) <= 0) { + snprintf(tmp,sizeof(tmp)-1,"fd %d: recv",fds[i]);//hopefully this doesn't error and throw off error messages. + perror(tmp); + return 2; + } if(bllen[i]+n > blsize[i]) {//this is probably off... t=malloc(blsize[i]+n); if(!t) exit(253); -- cgit v1.2.3