]> code.delx.au - pulseaudio/blobdiff - src/pulsecore/socket-client.c
Whitespace cleanup: Remove all multiple newlines
[pulseaudio] / src / pulsecore / socket-client.c
index b9d695055c2a56a9f5c8f2e6e1c787b5afa836ef..a12757a8d6c7e6c1f082fb3ec3e93afcad4ce6fc 100644 (file)
 #include <string.h>
 #include <stdlib.h>
 
-#ifdef HAVE_SYS_SOCKET_H
-#include <sys/socket.h>
-#endif
 #ifdef HAVE_SYS_UN_H
 #include <sys/un.h>
 #endif
-#ifdef HAVE_ARPA_INET_H
-#include <arpa/inet.h>
-#endif
 #ifdef HAVE_NETINET_IN_H
 #include <netinet/in.h>
 #endif
@@ -56,9 +50,9 @@
 #include <pulse/timeval.h>
 #include <pulse/xmalloc.h>
 
-#include <pulsecore/winsock.h>
-#include <pulsecore/core-error.h>
+#include <pulsecore/socket.h>
 #include <pulsecore/socket-util.h>
+#include <pulsecore/core-error.h>
 #include <pulsecore/core-rtclock.h>
 #include <pulsecore/core-util.h>
 #include <pulsecore/socket-util.h>
@@ -66,6 +60,7 @@
 #include <pulsecore/parseaddr.h>
 #include <pulsecore/macro.h>
 #include <pulsecore/refcnt.h>
+#include <pulsecore/arpa-inet.h>
 
 #include "socket-client.h"
 
@@ -231,7 +226,6 @@ pa_socket_client* pa_socket_client_new_ipv4(pa_mainloop_api *m, uint32_t address
     return pa_socket_client_new_sockaddr(m, (struct sockaddr*) &sa, sizeof(sa));
 }
 
-
 pa_socket_client* pa_socket_client_new_unix(pa_mainloop_api *m, const char *filename) {
 #ifdef HAVE_SYS_UN_H
     struct sockaddr_un sa;
@@ -257,13 +251,11 @@ static int sockaddr_prepare(pa_socket_client *c, const struct sockaddr *sa, size
 
     c->local = pa_socket_address_is_local(sa);
 
-    if ((c->fd = socket(sa->sa_family, SOCK_STREAM, 0)) < 0) {
+    if ((c->fd = pa_socket_cloexec(sa->sa_family, SOCK_STREAM, 0)) < 0) {
         pa_log("socket(): %s", pa_cstrerror(errno));
         return -1;
     }
 
-    pa_make_fd_cloexec(c->fd);
-
 #ifdef HAVE_IPV6
     if (sa->sa_family == AF_INET || sa->sa_family == AF_INET6)
 #else
@@ -389,7 +381,8 @@ static void asyncns_cb(pa_mainloop_api*m, pa_io_event *e, int fd, pa_io_event_fl
         goto fail;
 
     if (res->ai_addr)
-        sockaddr_prepare(c, res->ai_addr, res->ai_addrlen);
+        if (sockaddr_prepare(c, res->ai_addr, res->ai_addrlen) < 0)
+            goto fail;
 
     asyncns_freeaddrinfo(res);
 
@@ -526,7 +519,7 @@ pa_socket_client* pa_socket_client_new_string(pa_mainloop_api *m, pa_bool_t use_
                 if (!host)
                     goto finish;
 
-                pa_zero(sa);
+                pa_zero(s);
                 s.sin_family = AF_INET;
                 memcpy(&s.sin_addr, host->h_addr, sizeof(struct in_addr));
                 s.sin_port = htons(a.port);