Changeset: 3f9a6a208949 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=3f9a6a208949
Modified Files:
        clients/src/mapilib/Mapi.mx
Branch: default
Log Message:

mapi_mapi: make sure mid->hostname is set

Move automagic default of mid->hostname up to mapi_mapi, such that
mid->hostname is set before set_uri is being called, which requires
mid->hostname to be set.


diffs (42 lines):

diff -r fb303892d3d6 -r 3f9a6a208949 clients/src/mapilib/Mapi.mx
--- a/clients/src/mapilib/Mapi.mx       Wed Jan 05 11:39:42 2011 +0100
+++ b/clients/src/mapilib/Mapi.mx       Wed Jan 05 13:52:34 2011 +0100
@@ -2198,6 +2198,22 @@
 
        if (port == 0) {
                port = 50000;   /* hardwired default */
+               if (mid->hostname == NULL) {
+#ifdef HAVE_SYS_UN_H
+                       char buf[1024];
+                       struct stat st;
+                       snprintf(buf, sizeof(buf),
+                                CLIENTS_PREFIX 
"/var/MonetDB5/dbfarm/mapi_socket");
+                       if (strlen(buf) <= sizeof(((struct sockaddr_un *) 
0)->sun_path) &&
+                                       stat(buf, &st) != -1 &&
+                                       S_ISSOCK(st.st_mode))
+                       {
+                               mid->hostname = strdup(buf);
+                       } else {
+#endif
+                               mid->hostname = strdup("localhost");
+                       }
+               }
        } else {
                /* make sure we won't search for a unix socket first */
                if (mid->hostname == NULL)
@@ -2381,15 +2397,6 @@
                close_connection(mid);
 
 #ifdef HAVE_SYS_UN_H
-       if (mid->hostname == NULL) {
-               struct stat st;
-               snprintf(errbuf, sizeof(errbuf),
-                        CLIENTS_PREFIX "/var/MonetDB5/dbfarm/mapi_socket");
-               if (strlen(errbuf) <= sizeof(((struct sockaddr_un *) 
0)->sun_path) &&
-                               stat(errbuf, &st) != -1 &&
-                               S_ISSOCK(st.st_mode))
-                       mid->hostname = strdup(errbuf);
-       }
        if (mid->hostname && mid->hostname[0] == '/') {
                struct msghdr msg;
                struct iovec vec;
_______________________________________________
Checkin-list mailing list
[email protected]
http://mail.monetdb.org/mailman/listinfo/checkin-list

Reply via email to