protocol: Added polling for ACK
This commit is contained in:
parent
45ffde4714
commit
90d2fe4d08
1 changed files with 16 additions and 12 deletions
|
@ -90,20 +90,24 @@ 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 = 0;
|
||||
int read = nn_recv(g_client_socket, &buf, NN_MSG, 0);
|
||||
|
||||
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);
|
||||
if (read <= 0) {
|
||||
criterion_perror("Could not read ack: %s.\n",
|
||||
read == -1 ? nn_strerror(errno) : "No data");
|
||||
abort();
|
||||
}
|
||||
|
||||
criterion_protocol_ack ack;
|
||||
pb_istream_t stream = pb_istream_from_buffer(buf, read);
|
||||
|
|
Loading…
Add table
Reference in a new issue