From cdcea14156ad9ad97fe2cb64a0ebb83a6cd80ae4 Mon Sep 17 00:00:00 2001 From: Snaipe Date: Fri, 6 May 2016 22:27:30 +0200 Subject: [PATCH] Revert "protocol: Added polling for ACK" This reverts commit 0c0fade8088ecb9d11f366c5921d0c0f1a0c3815. --- src/protocol/messages.c | 28 ++++++++++++---------------- 1 file changed, 12 insertions(+), 16 deletions(-) diff --git a/src/protocol/messages.c b/src/protocol/messages.c index bdb8a55..b3ddbec 100644 --- a/src/protocol/messages.c +++ b/src/protocol/messages.c @@ -90,24 +90,20 @@ void cr_send_to_runner(const criterion_protocol_msg *message) { abort(); } - struct nn_pollfd pfd = { - .fd = g_client_socket, - .events = NN_POLLIN, - }; - - if (nn_poll(&pfd, 1, INT_MAX) != 1) { - criterion_perror("Could not poll for ack: %s.\n", nn_strerror(errno)); - abort(); - } - unsigned char *buf = NULL; - int read = nn_recv(g_client_socket, &buf, NN_MSG, 0); + int read = 0; - if (read <= 0) { - criterion_perror("Could not read ack: %s.\n", - read == -1 ? nn_strerror(errno) : "No data"); - abort(); - } + do { + read = nn_recv(g_client_socket, &buf, NN_MSG, 0); + + if (read <= 0) { + if (read == -1 && errno == EFSM) + continue; + criterion_perror("Could not read ack: %s.\n", nn_strerror(errno)); + abort(); + } + break; + } while (true); criterion_protocol_ack ack; pb_istream_t stream = pb_istream_from_buffer(buf, read);