aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--sircbot.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/sircbot.c b/sircbot.c
index fdb9b8c..32db75c 100644
--- a/sircbot.c
+++ b/sircbot.c
@@ -343,13 +343,21 @@ static int irc_loop(struct irc_session *sess, struct sircbot_channel *chan,
send_fifo_queue(sess, &chan[i-1], now) < 0)
goto ret_err;
- if (!(fds[i].revents))
+ if (fds[i].revents & POLLHUP)
+ return 0;
+
+ if (fds[i].revents & POLLERR)
+ goto ret_err;
+
+ if (!(fds[i].revents & POLLIN))
continue; /* no data available for read */
printf("DEBUG: data available from fds[%i]\n", i);
r = read(fds[i].fd, buf, sizeof(buf)-1);
if (r < 0)
goto ret_err;
+ if (r == 0)
+ continue;
printf("DEBUG: read %i bytes\n", r);