about summary refs log tree commit diff
path: root/sami.c
diff options
context:
space:
mode:
Diffstat (limited to 'sami.c')
-rw-r--r--sami.c16
1 files changed, 12 insertions, 4 deletions
diff --git a/sami.c b/sami.c
index 69f0796..8ae01c6 100644
--- a/sami.c
+++ b/sami.c
@@ -2,6 +2,7 @@
 
 #include <errno.h>
 #include <signal.h>
+#include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
 
@@ -20,6 +21,9 @@ static SAMI actors[ACTORS_MAX];
 char buffer[MESSAGE_LENGTH_MAX];
 static int self_fd;
 
+#define log(level, message) \
+	fprintf("%s:%d [%s]: %s\n", __FILE__, __LINE__, level, message)
+
 static ssize_t findspace(void)
 {
 	size_t i;
@@ -59,10 +63,10 @@ retry:
 		waitpid(-1, 0, WNOHANG);
 		res = poll(pfd, ACTORS_MAX, 0);
 		if (res == -1)
-			if (errno = EINTR)
+			if (errno == EINTR)
 				goto retry;
-			else /* TODO: log fail */
-				exit(1);
+			else
+				log("CRITICAL", strerror(errno)), exit(1);
 		else if (res == 0)
 			goto retry;
 
@@ -72,7 +76,11 @@ retry:
 				break;
 
 			sz = recv(pfd[i].fd, buffer, sizeof(buffer), 0);
-			/* TODO: log if sz == -1 */
+			if (sz == -1)
+			{
+				log("WARNING", strerror(errno));
+				continue;
+			}
 			if (handler(&actor[i], buffer, sz))
 				goto end;
 		}