]> git.ipfire.org Git - thirdparty/chrony.git/commitdiff
privops: use SOCK_SEQPACKET sockets when supported
authorMiroslav Lichvar <mlichvar@redhat.com>
Tue, 8 Dec 2015 09:20:20 +0000 (10:20 +0100)
committerMiroslav Lichvar <mlichvar@redhat.com>
Tue, 8 Dec 2015 16:38:56 +0000 (17:38 +0100)
SOCK_SEQPACKET is preferred over SOCK_DGRAM for communication with the
helper as the process will get an error when the other end of the socket
is closed. It's not supported on all platforms.

If SOCK_SEQPACKET is defined, try creating the pair of sockets with this
type first and if that fails, fall back to SOCK_DGRAM.

privops.c

index d53583c847090336df146e2109ee84701d24dd6a..82b56602d9ca2ee844924a89dccdd16c54763a9a 100644 (file)
--- a/privops.c
+++ b/privops.c
@@ -450,7 +450,11 @@ PRV_Initialise(void)
   if (have_helper())
     LOG_FATAL(LOGF_PrivOps, "Helper already running");
 
-  if (socketpair(AF_UNIX, SOCK_DGRAM, 0, sock_pair))
+  if (
+#ifdef SOCK_SEQPACKET
+      socketpair(AF_UNIX, SOCK_SEQPACKET, 0, sock_pair) &&
+#endif
+      socketpair(AF_UNIX, SOCK_DGRAM, 0, sock_pair))
     LOG_FATAL(LOGF_PrivOps, "socketpair() failed : %s", strerror(errno));
 
   UTI_FdSetCloexec(sock_pair[0]);