]> git.ipfire.org Git - thirdparty/chrony.git/commitdiff
client: fix binding of Unix socket on Solaris
authorMiroslav Lichvar <mlichvar@redhat.com>
Fri, 18 Sep 2015 10:05:44 +0000 (12:05 +0200)
committerMiroslav Lichvar <mlichvar@redhat.com>
Fri, 18 Sep 2015 14:42:40 +0000 (16:42 +0200)
bind() needs to be called before connect(), otherwise it fails with
EINVAL.

client.c

index 39b5d448af4f199a9bfe98bdf090bcac966a854d..60f53fcdc2a77d26b7b6924aee8b2571c9492ac3 100644 (file)
--- a/client.c
+++ b/client.c
@@ -209,11 +209,6 @@ prepare_socket(union sockaddr_all *addr)
     return 0;
   }
 
-  if (connect(sock_fd, &addr->sa, addr_len) < 0) {
-    DEBUG_LOG(LOGF_Client, "Could not connect socket : %s", strerror(errno));
-    return 0;
-  }
-
   if (addr->sa.sa_family == AF_UNIX) {
     struct sockaddr_un sa_un;
 
@@ -242,6 +237,11 @@ prepare_socket(union sockaddr_all *addr)
     }
   }
 
+  if (connect(sock_fd, &addr->sa, addr_len) < 0) {
+    DEBUG_LOG(LOGF_Client, "Could not connect socket : %s", strerror(errno));
+    return 0;
+  }
+
   return 1;
 }