From c18bfc11d74404aa6e3977b59727f646f7cc98b7 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Bart=C5=82omiej=20Piotrowski?= <b@bpiotrowski.pl>
Date: Mon, 15 Dec 2014 20:05:13 +0100
Subject: [PATCH] Check if sent() returned correctly, otherwise print errno
 message

---
 fanout.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/fanout.c b/fanout.c
index d6056f5..6688638 100644
--- a/fanout.c
+++ b/fanout.c
@@ -545,8 +545,15 @@ xit\n");
                 if (client_limit > 0 && current_count >= client_limit) {
                     fanout_debug (1, "hit connection limit of: %d\n",
                                    client_limit);
-                    send (client_i->fd, "debug!busy\n",
+
+                    errno = 0;
+                    ssize_t sentout = send (client_i->fd, "debug!busy\n",
                            strlen ("debug!busy\n"), 0);
+
+                    if ((sentout == -1) && errno) {
+                        fanout_debug (0, "%s\n", strerror (errno));
+                    }
+
                     close (client_i->fd);
                     free (client_i);
                     if (client_limit_count == ULLONG_MAX) {
-- 
GitLab