Changeset: d24e8c48ca7a for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=d24e8c48ca7a
Branch: default
Log Message:

Merge branch listenaddr into default.


diffs (truncated from 1793 to 300 lines):

diff --git a/clients/mapiclient/mclient.c b/clients/mapiclient/mclient.c
--- a/clients/mapiclient/mclient.c
+++ b/clients/mapiclient/mclient.c
@@ -3144,9 +3144,6 @@ usage(const char *prog, int xit)
        exit(xit);
 }
 
-/* hardwired defaults, only used if monet environment cannot be found */
-#define defaultPort 50000
-
 static inline bool
 isfile(FILE *fp)
 {
diff --git a/clients/mapilib/mapi.c b/clients/mapilib/mapi.c
--- a/clients/mapilib/mapi.c
+++ b/clients/mapilib/mapi.c
@@ -2237,7 +2237,7 @@ mapi_reconnect(Mapi mid)
                } else if (mid->database == NULL) {
                        /* case 1) */
                        if (port == 0)
-                               port = 50000;   /* case 1a), hardwired default 
*/
+                               port = MAPI_PORT;       /* case 1a), hardwired 
default */
                        if (host == NULL)
                                host = "localhost";
                } else {
@@ -2261,11 +2261,11 @@ mapi_reconnect(Mapi mid)
                                        /* see comment above for why
                                         * we don't stat */
                                        snprintf(buf, sizeof(buf),
-                                                "%s/.s.monetdb.50000", host);
+                                                        "%s/.s.monetdb.%d", 
host, MAPI_PORT);
                                        host = buf;
                                }
 #endif
-                               port = 50000;
+                               port = MAPI_PORT;
                        } else {
                                /* case 2b), no host, no port, but a
                                 * dbname, search for meros */
@@ -2336,7 +2336,7 @@ mapi_reconnect(Mapi mid)
                                /* case 2bIII) resort to TCP
                                 * connection on hardwired port */
                                host = "localhost";
-                               port = 50000;
+                               port = MAPI_PORT;
                        }
                }
                if (host != mid->hostname) {
@@ -2353,7 +2353,6 @@ mapi_reconnect(Mapi mid)
                struct msghdr msg;
                struct iovec vec;
                struct sockaddr_un userver;
-               struct sockaddr *serv = (struct sockaddr *) &userver;
 
                if (strlen(mid->hostname) >= sizeof(userver.sun_path)) {
                        return mapi_setError(mid, "path name too long", 
__func__, MERROR);
@@ -2382,7 +2381,7 @@ mapi_reconnect(Mapi mid)
                };
                strcpy_len(userver.sun_path, mid->hostname, 
sizeof(userver.sun_path));
 
-               if (connect(s, serv, sizeof(struct sockaddr_un)) == 
SOCKET_ERROR) {
+               if (connect(s, (struct sockaddr *) &userver, sizeof(struct 
sockaddr_un)) == SOCKET_ERROR) {
                        snprintf(errbuf, sizeof(errbuf),
                                 "initiating connection on socket failed: %s",
 #ifdef _MSC_VER
@@ -2421,7 +2420,6 @@ mapi_reconnect(Mapi mid)
        } else
 #endif
        {
-#ifdef HAVE_GETADDRINFO
                struct addrinfo hints, *res, *rp;
                char port[32];
                int ret;
@@ -2456,12 +2454,12 @@ mapi_reconnect(Mapi mid)
                                closesocket(s);
                        }
                        snprintf(errbuf, sizeof(errbuf),
-                                "could not connect to %s:%s: %s",
-                                mid->hostname, port,
+                                        "could not connect to %s:%s: %s",
+                                        mid->hostname, port,
 #ifdef _MSC_VER
                                         wsaerror(WSAGetLastError())
 #else
-                                strerror(errno)
+                                        strerror(errno)
 #endif
                                );
                }
@@ -2474,75 +2472,28 @@ mapi_reconnect(Mapi mid)
                        }
                        return mapi_setError(mid, errbuf, __func__, MERROR);
                }
-#else
-               struct sockaddr_in server;
-               struct hostent *hp;
-               struct sockaddr *serv = (struct sockaddr *) &server;
-
-               if (mid->hostname == NULL)
-                       mid->hostname = strdup("localhost");
-
-               if ((hp = gethostbyname(mid->hostname)) == NULL) {
-                       snprintf(errbuf, sizeof(errbuf), "gethostbyname failed: 
%s",
-#ifdef _MSC_VER
-                                wsaerror(WSAGetLastError())
-#else
-                                errno ? strerror(errno) : hstrerror(h_errno)
-#endif
-                               );
-                       return mapi_setError(mid, errbuf, __func__, MERROR);
-               }
-               server = (struct sockaddr_in) {
-                       .sin_family = hp->h_addrtype,
-                       .sin_port = htons((unsigned short) mid->port),
-               };
-               memcpy(&server.sin_addr, hp->h_addr_list[0], hp->h_length);
-               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",
-#ifdef _MSC_VER
-                                wsaerror(WSAGetLastError())
-#else
-                                strerror(errno)
-#endif
-                               );
-                       return mapi_setError(mid, errbuf, __func__, MERROR);
-               }
-#if !defined(SOCK_CLOEXEC) && defined(HAVE_FCNTL)
-               (void) fcntl(s, F_SETFD, FD_CLOEXEC);
-#endif
-
-               if (connect(s, serv, sizeof(server)) == SOCKET_ERROR) {
-                       snprintf(errbuf, sizeof(errbuf),
-                                "initiating connection on socket failed: %s",
-#ifdef _MSC_VER
-                                wsaerror(WSAGetLastError())
-#else
-                                strerror(errno)
-#endif
-                               );
-                       return mapi_setError(mid, errbuf, __func__, MERROR);
-               }
-#endif
                /* compare our own address with that of our peer and
                 * if they are the same, we were connected to our own
                 * socket, so then we can't use this connection */
                union {
-                       struct sockaddr s;
-                       struct sockaddr_in i;
+                       struct sockaddr_storage ss;
+                       struct sockaddr_in i4;
+                       struct sockaddr_in6 i6;
                } myaddr, praddr;
                socklen_t myaddrlen, praddrlen;
-               myaddrlen = (socklen_t) sizeof(myaddr);
-               praddrlen = (socklen_t) sizeof(praddr);
-               if (getsockname(s, &myaddr.s, &myaddrlen) == 0 &&
-                   getpeername(s, &praddr.s, &praddrlen) == 0 &&
-                   myaddr.i.sin_addr.s_addr == praddr.i.sin_addr.s_addr &&
-                   myaddr.i.sin_port == praddr.i.sin_port) {
+               myaddrlen = (socklen_t) sizeof(myaddr.ss);
+               praddrlen = (socklen_t) sizeof(praddr.ss);
+               if (getsockname(s, (struct sockaddr *) &myaddr.ss, &myaddrlen) 
== 0 &&
+                   getpeername(s, (struct sockaddr *) &praddr.ss, &praddrlen) 
== 0 &&
+                       myaddr.ss.ss_family == praddr.ss.ss_family &&
+                       (myaddr.ss.ss_family == AF_INET
+                        ? myaddr.i4.sin_port == praddr.i4.sin_port
+                        : myaddr.i6.sin6_port == praddr.i6.sin6_port) &&
+                       (myaddr.ss.ss_family == AF_INET
+                        ? myaddr.i4.sin_addr.s_addr == 
praddr.i4.sin_addr.s_addr
+                        : memcmp(myaddr.i6.sin6_addr.s6_addr,
+                                         praddr.i6.sin6_addr.s6_addr,
+                                         sizeof(praddr.i6.sin6_addr.s6_addr)) 
== 0)) {
                        closesocket(s);
                        return mapi_setError(mid, "connected to self",
                                             __func__, MERROR);
@@ -2926,7 +2877,7 @@ mapi_reconnect(Mapi mid)
                                        if (q != NULL) {
                                                mid->port = atoi(q);
                                                if (mid->port == 0)
-                                                       mid->port = 50000;      
/* hardwired default */
+                                                       mid->port = MAPI_PORT;  
/* hardwired default */
                                        }
                                        db = red;
                                } else {
@@ -5562,4 +5513,3 @@ mapi_get_active(Mapi mid)
 {
        return mid->active;
 }
-
diff --git a/clients/odbc/driver/SQLConnect.c b/clients/odbc/driver/SQLConnect.c
--- a/clients/odbc/driver/SQLConnect.c
+++ b/clients/odbc/driver/SQLConnect.c
@@ -199,13 +199,13 @@ MNDBConnect(ODBCDbc *dbc,
        if (port == 0 && (s = getenv("MAPIPORT")) != NULL)
                port = atoi(s);
        if (port == 0 && dsn && *dsn) {
-               n = SQLGetPrivateProfileString(dsn, "port", "50000",
+               n = SQLGetPrivateProfileString(dsn, "port", MAPI_PORT_STR,
                                               buf, sizeof(buf), "odbc.ini");
                if (n > 0)
                        port = atoi(buf);
        }
        if (port == 0)
-               port = 50000;
+               port = MAPI_PORT;
 
        if (host == NULL || *host == 0) {
                host = "localhost";
diff --git a/clients/odbc/winsetup/setup.c b/clients/odbc/winsetup/setup.c
--- a/clients/odbc/winsetup/setup.c
+++ b/clients/odbc/winsetup/setup.c
@@ -258,7 +258,7 @@ ConfigDSN(HWND parent, WORD request, LPC
        MergeFromProfileString(data.dsn, &data.uid, "uid", "monetdb");
        MergeFromProfileString(data.dsn, &data.pwd, "pwd", "monetdb");
        MergeFromProfileString(data.dsn, &data.host, "host", "localhost");
-       MergeFromProfileString(data.dsn, &data.port, "port", "50000");
+       MergeFromProfileString(data.dsn, &data.port, "port", MAPI_PORT_STR);
        MergeFromProfileString(data.dsn, &data.database, "database", "");
 
        ODBCLOG("ConfigDSN values: dsn=%s uid=%s pwd=%s host=%s port=%s 
database=%s\n",
diff --git a/cmake/monetdb-defines.cmake b/cmake/monetdb-defines.cmake
--- a/cmake/monetdb-defines.cmake
+++ b/cmake/monetdb-defines.cmake
@@ -192,6 +192,9 @@ macro(monetdb_macro_variables)
     message(FATAL_ERROR "PCRE library or GNU regex library not found but 
required for MonetDB5")
   endif()
 
+  set(MAPI_PORT 50000)
+  set(MAPI_PORT_STR "${MAPI_PORT}")
+
   set(DIR_SEP  "/")
   set(PATH_SEP ":")
   set(DIR_SEP_STR  "/")
diff --git a/common/options/monet_options.c b/common/options/monet_options.c
--- a/common/options/monet_options.c
+++ b/common/options/monet_options.c
@@ -218,7 +218,7 @@ mo_builtin_settings(opt **Set)
        if (Set == NULL)
                return 0;
 
-#define N_OPTIONS      8       /*MUST MATCH # OPTIONS BELOW */
+#define N_OPTIONS      5       /*MUST MATCH # OPTIONS BELOW */
        set = malloc(sizeof(opt) * N_OPTIONS);
        if (set == NULL)
                return 0;
@@ -230,19 +230,7 @@ mo_builtin_settings(opt **Set)
        i++;
        set[i].kind = opt_builtin;
        set[i].name = strdup("mapi_port");
-       set[i].value = strdup("50000");
-       i++;
-       set[i].kind = opt_builtin;
-       set[i].name = strdup("mapi_open");
-       set[i].value = strdup("false");
-       i++;
-       set[i].kind = opt_builtin;
-       set[i].name = strdup("mapi_ipv6");
-       set[i].value = strdup("false");
-       i++;
-       set[i].kind = opt_builtin;
-       set[i].name = strdup("mapi_autosense");
-       set[i].value = strdup("false");
+       set[i].value = strdup(MAPI_PORT_STR);
        i++;
        set[i].kind = opt_builtin;
        set[i].name = strdup("sql_optimizer");
diff --git a/documentation/source/manual_pages/mserver5.rst.in 
b/documentation/source/manual_pages/mserver5.rst.in
--- a/documentation/source/manual_pages/mserver5.rst.in
+++ b/documentation/source/manual_pages/mserver5.rst.in
@@ -65,7 +65,7 @@ MSERVER5 OPTIONS
 
 **--config=**\ *file*
    Config file to read options from. This file can contain all options
-   as can be set with the --set flag. See *CONFIG FILE FORMAT*.
+   as can be set with the **--set** flag. See *CONFIG FILE FORMAT*.
 
 **--single-user**
    Allow only a single user at a time.
@@ -202,8 +202,53 @@ distributed) plans. These parameters con
    same time. Note that MonetDB is not designed to handle massive
    amounts of connected clients. The funnel capability from
    *monetdbd*\ (1) might be a more suitable solution for such workloads.
+   Default **64**.
 
-Default **64**.
+**mapi_usock**
+   The name of the UNIX domain socket file on which the server will
+   listen for connections. Note, there is usually a severe
+   system-imposed length limitation on the name of the file.
+
+**mapi_port**
+   The TCP/IP port number on which the server will listen for
+   connections. This is only used if the value of the
+   **mapi_listenaddr** option is not equal to **none**. Default
_______________________________________________
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to