From 05cc7b1087e69b531618d4bda6d3010b34208d1d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adrien=20Gallou=C3=ABt?= Date: Tue, 6 Sep 2016 08:45:53 +0000 Subject: [PATCH] Be more verbose when mud fails --- src/main.c | 33 ++++++++++++++++++++++----------- 1 file changed, 22 insertions(+), 11 deletions(-) diff --git a/src/main.c b/src/main.c index 40be8b1..f24aea9 100644 --- a/src/main.c +++ b/src/main.c @@ -453,25 +453,36 @@ int main (int argc, char **argv) } } - if (send_limit && mud_send(mud, send.buf, send_limit, send_tc)==send_limit) { - if (send_size>send_limit) - memmove(&send.buf[0], &send.buf[send_limit], send_size-send_limit); - send_size -= send_limit; - send_limit = send_size; - send_tc = send_next_tc; - send_next_tc = 0; + if (send_limit) { + int r = mud_send(mud, send.buf, send_limit, send_tc); + if (r==-1 && errno!=EAGAIN) { + perror("mud_send"); + } else if (r==send_limit) { + if (send_size>send_limit) + memmove(&send.buf[0], &send.buf[send_limit], send_size-send_limit); + send_size -= send_limit; + send_limit = send_size; + send_tc = send_next_tc; + send_next_tc = 0; + } } - mud_push(mud); + if (mud_push(mud)==-1 && errno!=EAGAIN) + perror("mud_push"); - if (FD_ISSET(mud_fd, &rfds)) - mud_pull(mud); + if (FD_ISSET(mud_fd, &rfds)) { + if (mud_pull(mud)==-1 && errno!=EAGAIN) + perror("mud_pull"); + } while (!gt.quit) { const int size = mud_recv(mud, recv.buf, mtu); - if (size<=0) + if (size<=0) { + if (size==-1 && errno!=EAGAIN) + perror("mud_recv"); break; + } int p = 0;