]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: sink: set the fd-type sinks to non-blocking
authorWilly Tarreau <w@1wt.eu>
Tue, 27 Aug 2019 08:34:32 +0000 (10:34 +0200)
committerWilly Tarreau <w@1wt.eu>
Tue, 27 Aug 2019 15:14:18 +0000 (17:14 +0200)
Just like we used to do for the logs, we must disable blocking on FD
output except if it's a terminal.

src/sink.c

index f3e18ccb20c09bf0d49d84a8c6ef07a9e917950a..214b272ef430b4c7ea895a2321c5b2a950d5cba5 100644 (file)
@@ -19,6 +19,8 @@
  */
 
 #include <sys/uio.h>
+#include <fcntl.h>
+#include <unistd.h>
 #include <common/compat.h>
 #include <common/config.h>
 #include <common/ist.h>
@@ -89,6 +91,11 @@ struct sink *sink_new_fd(const char *name, const char *desc, enum sink_fmt fmt,
                goto end;
        }
 
+       /* FD not yet initialized to non-blocking mode.
+        * DON'T DO IT ON A TERMINAL!
+        */
+       if (!isatty(fd))
+               fcntl(fd, F_SETFL, O_NONBLOCK);
        sink->type = SINK_TYPE_FD;
        sink->ctx.fd = fd;
  end: