From 33d4d3c9f1307034295e486c8d54bdcd82f8ab1c Mon Sep 17 00:00:00 2001 From: Snaipe Date: Mon, 25 Apr 2016 22:45:39 +0200 Subject: [PATCH] protocol: Loop on FSM errors --- src/protocol/messages.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/protocol/messages.c b/src/protocol/messages.c index 4c0c3f7..295d874 100644 --- a/src/protocol/messages.c +++ b/src/protocol/messages.c @@ -91,12 +91,18 @@ void cr_send_to_runner(const criterion_protocol_msg *message) { } 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", nn_strerror(errno)); - 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(); + } + } while (read > 0); criterion_protocol_ack ack; pb_istream_t stream = pb_istream_from_buffer(buf, read);