X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=jam.c;h=9eab9c9cfd57d7b0b63859e7c049f016e184e639;hb=HEAD;hp=3156ba82b2945934d2728b6eeb393e14a49bba82;hpb=dd8d8f2fb3d1c0f8bb4c4652643a5f989b0e77bf;p=jam diff --git a/jam.c b/jam.c index 3156ba8..9eab9c9 100644 --- a/jam.c +++ b/jam.c @@ -42,6 +42,7 @@ const static struct option longopts[] = { { "destination-list", required_argument, NULL, 'd' }, { "num-senders", required_argument, NULL, 'n' }, { "num-sockets-per-sender", required_argument, NULL, 'N' }, + { "num-receivers", required_argument, NULL, 'r' }, { "port", required_argument, NULL, 'p' }, { "sender-only", no_argument, NULL, 'o' }, { NULL, 0, NULL, 0 } @@ -119,7 +120,7 @@ void parse_options(int argc, char **argv) int option_index = 0; for ( ;; ) { - int c = getopt_long(argc, argv, "s:d:n:N:p:o", longopts, &option_index); + int c = getopt_long(argc, argv, "s:d:n:N:r:p:o", longopts, &option_index); switch (c) { case 's': read_ip_list(optarg, &sources, &num_sources, &room_sources); @@ -130,6 +131,9 @@ void parse_options(int argc, char **argv) case 'n': num_senders = atoi(optarg); break; + case 'r': + num_receivers = atoi(optarg); + break; case 'N': num_sockets_per_sender = atoi(optarg); break; @@ -241,6 +245,8 @@ void *sender_worker(void *arg) for ( ;; ) { int num_active = epoll_wait(ep_fd, events, num_sockets_per_sender, -1); if (num_active == -1) { + if (errno == EINTR) + continue; perror("epoll_wait"); exit(1); } @@ -256,7 +262,7 @@ void *sender_worker(void *arg) ret = send(s->fd, buf, bytes_to_send, MSG_NOSIGNAL); if (ret == -1) { - if (errno == EAGAIN) + if (errno == EAGAIN || errno == EINTR) continue; perror("send()"); @@ -330,6 +336,8 @@ void *receiver_worker(void *arg) for ( ;; ) { int num_active = epoll_wait(ep_fd, events, epoll_room_in_receiver, -1); if (num_active == -1) { + if (errno == EINTR) + continue; perror("epoll_wait"); exit(1); } @@ -344,7 +352,7 @@ void *receiver_worker(void *arg) sock = accept(server_sock, (struct sockaddr *)&addr, &addr_len); if (sock == -1) { - if (errno == EAGAIN) { + if (errno == EAGAIN || errno == EINTR) { // another thread snatched it, ignore continue; } else {