]> git.ipfire.org Git - thirdparty/chrony.git/commitdiff
ntp: enable non-blocking mode on server sockets
authorMiroslav Lichvar <mlichvar@redhat.com>
Mon, 21 May 2018 14:27:43 +0000 (16:27 +0200)
committerMiroslav Lichvar <mlichvar@redhat.com>
Fri, 25 May 2018 08:53:21 +0000 (10:53 +0200)
Avoid blocking in sendmsg() due to a full send buffer.

ntp_io.c

index 5c8c47a997924c7a1fbc4952cb1dcbbf0725bd4c..3a3398ac90d160d5324ce50c142d0f3285becccc 100644 (file)
--- a/ntp_io.c
+++ b/ntp_io.c
@@ -142,6 +142,10 @@ prepare_socket(int family, int port_number, int client_only)
   /* Close on exec */
   UTI_FdSetCloexec(sock_fd);
 
+  /* Enable non-blocking mode on server sockets */
+  if (!client_only && fcntl(sock_fd, F_SETFL, O_NONBLOCK))
+    DEBUG_LOG("Could not set O_NONBLOCK : %s", strerror(errno));
+
   /* Prepare local address */
   memset(&my_addr, 0, sizeof (my_addr));
   my_addr_len = 0;