Changeset: ef2036e0cbb4 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=ef2036e0cbb4
Modified Files:
        clients/mapiclient/mnc.c
        clients/mapilib/mapi.c
        common/stream/stream.c
        monetdb5/modules/mal/mal_mapi.c
        tools/merovingian/daemon/client.c
        tools/merovingian/daemon/connections.c
        tools/merovingian/daemon/controlrunner.c
        tools/merovingian/daemon/merovingian.c
        tools/merovingian/daemon/proxy.c
        tools/merovingian/utils/control.c
Branch: Jul2017
Log Message:

Compilation issues.
It doesn't help if SOCK_CLOEXEC is defined both as an enum and using
#define SOCK_CLOEXEC SOCK_CLOEXEC
You then can't use #if SOCK_CLOEXEC == 0.


diffs (truncated from 557 to 300 lines):

diff --git a/clients/mapiclient/mnc.c b/clients/mapiclient/mnc.c
--- a/clients/mapiclient/mnc.c
+++ b/clients/mapiclient/mnc.c
@@ -58,11 +58,7 @@
 #define SOCKLEN int
 #endif
 
-#ifndef SOCK_CLOEXEC
-#define SOCK_CLOEXEC           0
-#endif
-
-#ifndef HAVE_ACCEPT4
+#if !defined(HAVE_ACCEPT4) || !defined(SOCK_CLOEXEC)
 #define accept4(sockfd, addr, addlen, flags)   accept(sockfd, addr, addrlen)
 #endif
 
@@ -172,14 +168,18 @@ main(int argc, char **argv)
                        exit(1);
                }
                for (rp = res; rp; rp = rp->ai_next) {
-                       s = socket(rp->ai_family, rp->ai_socktype | 
SOCK_CLOEXEC, rp->ai_protocol);
+                       s = socket(rp->ai_family, rp->ai_socktype
+#ifdef SOCK_CLOEXEC
+                                  | SOCK_CLOEXEC
+#endif
+                                  , rp->ai_protocol);
                        if (s == INVALID_SOCKET)
                                continue;
                        if (connect(s, rp->ai_addr, (socklen_t) rp->ai_addrlen) 
!= SOCKET_ERROR)
                                break;  /* success */
                        closesocket(s);
                }
-#if SOCK_CLOEXEC == 0 && defined(HAVE_FCNTL)
+#if !defined(SOCK_CLOEXEC) && defined(HAVE_FCNTL)
                (void) fcntl(s, F_SETFD, FD_CLOEXEC);
 #endif
                freeaddrinfo(res);
@@ -201,13 +201,17 @@ main(int argc, char **argv)
                memcpy(&server.sin_addr, hp->h_addr_list[0], hp->h_length);
                server.sin_family = hp->h_addrtype;
                server.sin_port = htons((unsigned short) (port & 0xFFFF));
-               s = socket(server.sin_family, SOCK_STREAM | SOCK_CLOEXEC, 
IPPROTO_TCP);
+               s = socket(server.sin_family, SOCK_STREAM
+#ifdef SOCK_CLOEXEC
+                          | SOCK_CLOEXEC
+#endif
+                          , IPPROTO_TCP);
 
                if (s == INVALID_SOCKET) {
                        fprintf(stderr, "opening socket failed: %s\n", 
strerror(errno));
                        exit(1);
                }
-#if SOCK_CLOEXEC == 0 && defined(HAVE_FCNTL)
+#if !defined(SOCK_CLOEXEC) && defined(HAVE_FCNTL)
                (void) fcntl(s, F_SETFD, FD_CLOEXEC);
 #endif
 
@@ -230,11 +234,15 @@ main(int argc, char **argv)
                        exit(1);
                }
 
-               if ((sock = socket(AF_INET, SOCK_STREAM | SOCK_CLOEXEC, 0)) == 
INVALID_SOCKET) {
+               if ((sock = socket(AF_INET, SOCK_STREAM
+#ifdef SOCK_CLOEXEC
+                                  | SOCK_CLOEXEC
+#endif
+                                  , 0)) == INVALID_SOCKET) {
                        fprintf(stderr, "failed to create socket: %s\n", 
strerror(errno));
                        exit(1);
                }
-#if SOCK_CLOEXEC == 0 && defined(HAVE_FCNTL)
+#if !defined(SOCK_CLOEXEC) && defined(HAVE_FCNTL)
                (void) fcntl(sock, F_SETFD, FD_CLOEXEC);
 #endif
 
@@ -259,7 +267,7 @@ main(int argc, char **argv)
                                        strerror(errno));
                        exit(1);
                }
-#if defined(HAVE_FCNTL) && (SOCK_CLOEXEC == 0 || !defined(HAVE_ACCEPT4))
+#if defined(HAVE_FCNTL) && (!defined(SOCK_CLOEXEC) || !defined(HAVE_ACCEPT4))
                (void) fcntl(s, F_SETFD, FD_CLOEXEC);
 #endif
        }
diff --git a/clients/mapilib/mapi.c b/clients/mapilib/mapi.c
--- a/clients/mapilib/mapi.c
+++ b/clients/mapilib/mapi.c
@@ -774,10 +774,6 @@
 #define INVALID_SOCKET (-1)
 #endif
 
-#ifndef SOCK_CLOEXEC
-#define SOCK_CLOEXEC   0
-#endif
-
 #define MAPIBLKSIZE    256     /* minimum buffer shipped */
 
 /* information about the columns in a result set */
@@ -2369,7 +2365,11 @@ mapi_reconnect(Mapi mid)
                        return mapi_setError(mid, "path name too long", 
"mapi_reconnect", MERROR);
                }
 
-               if ((s = socket(PF_UNIX, SOCK_STREAM | SOCK_CLOEXEC, 0)) == 
INVALID_SOCKET) {
+               if ((s = socket(PF_UNIX, SOCK_STREAM
+#ifdef SOCK_CLOEXEC
+                               | SOCK_CLOEXEC
+#endif
+                               , 0)) == INVALID_SOCKET) {
                        snprintf(errbuf, sizeof(errbuf),
                                 "opening socket failed: %s",
 #ifdef _MSC_VER
@@ -2380,7 +2380,7 @@ mapi_reconnect(Mapi mid)
                                );
                        return mapi_setError(mid, errbuf, "mapi_reconnect", 
MERROR);
                }
-#if SOCK_CLOEXEC == 0 && defined(HAVE_FCNTL)
+#if !defined(SOCK_CLOEXEC) && defined(HAVE_FCNTL)
                (void) fcntl(s, F_SETFD, FD_CLOEXEC);
 #endif
                memset(&userver, 0, sizeof(struct sockaddr_un));
@@ -2446,10 +2446,14 @@ mapi_reconnect(Mapi mid)
                        return mapi_setError(mid, errbuf, "mapi_reconnect", 
MERROR);
                }
                for (rp = res; rp; rp = rp->ai_next) {
-                       s = socket(rp->ai_family, rp->ai_socktype | 
SOCK_CLOEXEC, rp->ai_protocol);
+                       s = socket(rp->ai_family, rp->ai_socktype
+#ifdef SOCK_CLOEXEC
+                                  | SOCK_CLOEXEC
+#endif
+                                  , rp->ai_protocol);
                        if (s == INVALID_SOCKET)
                                continue;
-#if SOCK_CLOEXEC == 0 && defined(HAVE_FCNTL)
+#if !defined(SOCK_CLOEXEC) && defined(HAVE_FCNTL)
                        (void) fcntl(s, F_SETFD, FD_CLOEXEC);
 #endif
                        if (connect(s, rp->ai_addr, (socklen_t) rp->ai_addrlen) 
!= SOCKET_ERROR)
@@ -2490,7 +2494,11 @@ mapi_reconnect(Mapi mid)
                memcpy(&server.sin_addr, hp->h_addr_list[0], hp->h_length);
                server.sin_family = hp->h_addrtype;
                server.sin_port = htons((unsigned short) (mid->port & 0xFFFF));
-               s = socket(server.sin_family, SOCK_STREAM | SOCK_CLOEXEC, 
IPPROTO_TCP);
+               s = socket(server.sin_family, SOCK_STREAM
+#ifdef SOCK_CLOEXEC
+                          | SOCK_CLOEXEC
+#endif
+                          , IPPROTO_TCP);
 
                if (s == INVALID_SOCKET) {
                        snprintf(errbuf, sizeof(errbuf), "opening socket 
failed: %s",
@@ -2502,7 +2510,7 @@ mapi_reconnect(Mapi mid)
                                );
                        return mapi_setError(mid, errbuf, "mapi_reconnect", 
MERROR);
                }
-#if SOCK_CLOEXEC == 0 && defined(HAVE_FCNTL)
+#if !defined(SOCK_CLOEXEC) && defined(HAVE_FCNTL)
                (void) fcntl(s, F_SETFD, FD_CLOEXEC);
 #endif
 
diff --git a/common/stream/stream.c b/common/stream/stream.c
--- a/common/stream/stream.c
+++ b/common/stream/stream.c
@@ -127,10 +127,6 @@
 #define INVALID_SOCKET (-1)
 #endif
 
-#ifndef SOCK_CLOEXEC
-#define SOCK_CLOEXEC   0
-#endif
-
 #ifdef NATIVE_WIN32
 #define pclose _pclose
 #define fileno(fd) _fileno(fd)
@@ -2687,10 +2683,14 @@ udp_socket(udp_stream *udp, const char *
                return -1;
        memset(&udp->addr, 0, sizeof(udp->addr));
        for (rp = res; rp; rp = rp->ai_next) {
-               udp->s = socket(rp->ai_family, rp->ai_socktype | SOCK_CLOEXEC, 
rp->ai_protocol);
+               udp->s = socket(rp->ai_family, rp->ai_socktype
+#ifdef SOCK_CLOEXEC
+                               | SOCK_CLOEXEC
+#endif
+                               , rp->ai_protocol);
                if (udp->s == INVALID_SOCKET)
                        continue;
-#if SOCK_CLOEXEC == 0 && defined(HAVE_FCNTL)
+#if !defined(SOCK_CLOEXEC) && defined(HAVE_FCNTL)
                (void) fcntl(udp->s, F_SETFD, FD_CLOEXEC);
 #endif
                if (!write &&
@@ -2726,10 +2726,14 @@ udp_socket(udp_stream *udp, const char *
        udp->addr.sin_port = htons((unsigned short) (port & 0xFFFF));
        serv = (struct sockaddr *) &udp->addr;
        servsize = (socklen_t) sizeof(udp->addr);
-       udp->s = socket(serv->sa_family, SOCK_DGRAM | SOCK_CLOEXEC, 
IPPROTO_UDP);
+       udp->s = socket(serv->sa_family, SOCK_DGRAM
+#ifdef SOCK_CLOEXEC
+                       | SOCK_CLOEXEC
+#endif
+                       , IPPROTO_UDP);
        if (udp->s == INVALID_SOCKET)
                return -1;
-#if SOCK_CLOEXEC == 0 && defined(HAVE_FCNTL)
+#if !defined(SOCK_CLOEXEC) && defined(HAVE_FCNTL)
        (void) fcntl(udp->s, F_SETFD, FD_CLOEXEC);
 #endif
        if (!write && bind(udp->s, serv, servsize) == SOCKET_ERROR)
diff --git a/monetdb5/modules/mal/mal_mapi.c b/monetdb5/modules/mal/mal_mapi.c
--- a/monetdb5/modules/mal/mal_mapi.c
+++ b/monetdb5/modules/mal/mal_mapi.c
@@ -72,11 +72,7 @@
 #define SOCKLEN int
 #endif
 
-#ifndef SOCK_CLOEXEC
-#define SOCK_CLOEXEC   0
-#endif
-
-#ifndef HAVE_ACCEPT4
+#if !defined(HAVE_ACCEPT4) || !defined(SOCK_CLOEXEC)
 #define accept4(sockfd, addr, addrlen, flags)  accept(sockfd, addr, addrlen)
 #endif
 
@@ -363,7 +359,7 @@ SERVERlistenThread(SOCKET *Sock)
                                }
                                continue;
                        }
-#if defined(HAVE_FCNTL) && (SOCK_CLOEXEC == 0 || !defined(HAVE_ACCEPT4))
+#if defined(HAVE_FCNTL) && (!defined(SOCK_CLOEXEC) || !defined(HAVE_ACCEPT4))
                        (void) fcntl(msgsock, F_SETFD, FD_CLOEXEC);
 #endif
 #ifdef HAVE_SYS_UN_H
@@ -388,7 +384,7 @@ SERVERlistenThread(SOCKET *Sock)
                                }
                                continue;
                        }
-#if defined(HAVE_FCNTL) && (SOCK_CLOEXEC == 0 || !defined(HAVE_ACCEPT4))
+#if defined(HAVE_FCNTL) && (!defined(SOCK_CLOEXEC) || !defined(HAVE_ACCEPT4))
                        (void) fcntl(msgsock, F_SETFD, FD_CLOEXEC);
 #endif
 
@@ -614,7 +610,11 @@ SERVERlisten(int *Port, str *Usockfile, 
        }
 
        if (port > 0) {
-               sock = socket(AF_INET, SOCK_STREAM | SOCK_CLOEXEC, 0);
+               sock = socket(AF_INET, SOCK_STREAM
+#ifdef SOCK_CLOEXEC
+                                         | SOCK_CLOEXEC
+#endif
+                                         , 0);
                if (sock == INVALID_SOCKET) {
                        GDKfree(psock);
                        if (usockfile)
@@ -628,7 +628,7 @@ SERVERlisten(int *Port, str *Usockfile, 
 #endif
                                );
                }
-#if SOCK_CLOEXEC == 0 && defined(HAVE_FCNTL)
+#if !defined(SOCK_CLOEXEC) && defined(HAVE_FCNTL)
                (void) fcntl(sock, F_SETFD, FD_CLOEXEC);
 #endif
 
@@ -707,7 +707,11 @@ SERVERlisten(int *Port, str *Usockfile, 
        }
 #ifdef HAVE_SYS_UN_H
        if (usockfile) {
-               usock = socket(AF_UNIX, SOCK_STREAM | SOCK_CLOEXEC, 0);
+               usock = socket(AF_UNIX, SOCK_STREAM
+#ifdef SOCK_CLOEXEC
+                                          | SOCK_CLOEXEC
+#endif
+                                          , 0);
                if (usock == INVALID_SOCKET ) {
                        GDKfree(psock);
                        GDKfree(usockfile);
@@ -720,7 +724,7 @@ SERVERlisten(int *Port, str *Usockfile, 
 #endif
                                );
                }
-#if SOCK_CLOEXEC == 0 && defined(HAVE_FCNTL)
+#if !defined(SOCK_CLOEXEC) && defined(HAVE_FCNTL)
                (void) fcntl(usock, F_SETFD, FD_CLOEXEC);
 #endif
 
diff --git a/tools/merovingian/daemon/client.c 
b/tools/merovingian/daemon/client.c
--- a/tools/merovingian/daemon/client.c
+++ b/tools/merovingian/daemon/client.c
@@ -36,11 +36,7 @@
 #include "client.h"
 #include "handlers.h"
 
-#ifndef SOCK_CLOEXEC
-#define SOCK_CLOEXEC   0
-#endif
-
-#ifndef HAVE_ACCEPT4
+#if !defined(HAVE_ACCEPT4) || !defined(SOCK_CLOEXEC)
 #define accept4(sockfd, addr, addrlen, flags)  accept(sockfd, addr, addrlen)
 #endif
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to