aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorepochqwert <epoch@hacking.allowed.org>2016-06-03 06:33:45 +0000
committerepochqwert <epoch@hacking.allowed.org>2016-06-03 06:33:45 +0000
commit57b66cfd6ad5f5504bab2bade4e031cc851498b4 (patch)
tree5f63b576fe7258280ea06e975a1fb6b36c3b4eb8
parentdbb59020a4f9dad43b366930d1d5d99da33e57e1 (diff)
downloadlibirc-57b66cfd6ad5f5504bab2bade4e031cc851498b4.tar.gz
libirc-57b66cfd6ad5f5504bab2bade4e031cc851498b4.zip
added a more descriptive recv error message.
-rw-r--r--libirc.c7
1 files changed, 6 insertions, 1 deletions
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);