socket_send does not crash anymore but returns an error

The application (enb.c basically) will now monitor the socket
and reconnect if it dies. See following commits.
This commit is contained in:
Cedric Roux
2016-06-05 13:10:52 +02:00
parent 51292c2472
commit 9338f06e90
5 changed files with 17 additions and 12 deletions
+4 -3
View File
@@ -30,9 +30,10 @@ void is_on_changed(void *_d)
if (d->socket == -1) goto no_connection;
t = 1;
socket_send(d->socket, &t, 1);
socket_send(d->socket, &d->nevents, sizeof(int));
socket_send(d->socket, d->is_on, d->nevents * sizeof(int));
if (socket_send(d->socket, &t, 1) == -1 ||
socket_send(d->socket, &d->nevents, sizeof(int)) == -1 ||
socket_send(d->socket, d->is_on, d->nevents * sizeof(int)) == -1)
abort();
no_connection:
if (pthread_mutex_unlock(&d->lock)) abort();