X-Git-Url: http://git.tuebingen.mpg.de/?p=paraslash.git;a=blobdiff_plain;f=recv.c;h=af15eb07efb005f8b959e764d74b1bf2a27db60d;hp=aaccb06ac77fcd7bded8ffc46c300039227eabe1;hb=839a32891754f3f162b73f88b58e04eab8032d7a;hpb=2ed89c59f0efcd0a2763f47c7d3455663241e623 diff --git a/recv.c b/recv.c index aaccb06a..af15eb07 100644 --- a/recv.c +++ b/recv.c @@ -15,18 +15,18 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA. */ -#include "gcc-compat.h" #include "para.h" #include "recv.h" #include "recv.cmdline.h" +#include "fd.h" #include "error.h" struct gengetopt_args_info conf; INIT_RECV_ERRLISTS; -__printf_2_3 void para_log(int ll, char* fmt,...) +__printf_2_3 void para_log(int ll, const char* fmt,...) { va_list argp; @@ -48,7 +48,8 @@ static void *parse_config(int argc, char *argv[], int *receiver_num) printf("available receivers: "); for (i = 0; receivers[i].name; i++) printf("%s%s", i? " " : "", receivers[i].name); - printf("\nTry para_recv -r:-h for help on \n"); + printf("\nTry\n\tpara_recv -r ' -h'\n" + "for help on .\n"); exit(EXIT_SUCCESS); } return check_receiver_arg(conf.receiver_arg, receiver_num); @@ -81,16 +82,14 @@ recv: FD_ZERO(&rfds); FD_ZERO(&wfds); timeout.tv_sec = 0; - timeout.tv_usec = 1000 * 1000; + timeout.tv_usec = 999 * 1000; max = -1; ret = r->pre_select(&rn, &rfds, &wfds, &timeout); - max = MAX(max, ret); + max = PARA_MAX(max, ret); - PARA_DEBUG_LOG("timeout: %lums\n", tv2ms(&timeout)); - ret = select(max + 1, &rfds, &wfds, NULL, &timeout); + PARA_DEBUG_LOG("timeout: %lums, max: %d\n", tv2ms(&timeout), max); + ret = para_select(max + 1, &rfds, &wfds, &timeout); if (ret < 0) { - if (errno == EINTR || errno == EAGAIN) - goto recv; ret = -E_RECV_SELECT; goto out; } @@ -105,13 +104,13 @@ recv: goto recv; } ret = write(STDOUT_FILENO, rn.buf, rn.loaded); - PARA_DEBUG_LOG("wrote %d/%d\n", ret, rn.loaded); + PARA_DEBUG_LOG("wrote %d/%zd\n", ret, rn.loaded); if (ret < 0) { ret = -E_WRITE_STDOUT; goto out; } if (ret != rn.loaded) { - PARA_INFO_LOG("short write %d/%d\n", ret, rn.loaded); + PARA_INFO_LOG("short write %d/%zd\n", ret, rn.loaded); memmove(rn.buf, rn.buf + ret, rn.loaded - ret); } rn.loaded -= ret; @@ -123,6 +122,6 @@ out: if (r) r->shutdown(); if (ret < 0) - PARA_NOTICE_LOG("%d: (%s)\n", ret, PARA_STRERROR(-ret)); + PARA_ERROR_LOG("%s\n", PARA_STRERROR(-ret)); return ret; }