Changeset: 986a0834e2fe for MonetDB URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=986a0834e2fe Modified Files: sql/src/backends/monet5/merovingian/ChangeLog.Jun2010 sql/src/backends/monet5/merovingian/merovingian.c sql/src/backends/monet5/merovingian/monetdb.c Branch: Jun2010 Log Message:
Work around UNIX domain socket length restriction of around 108 chars. The sun_path element is typically around only 108 chars long. This causes paths to be truncated. Find below list for the actual limits on sun_path and what it accepts in reality. I worked around the problem by using a relative socket file location (in the current working directory), such that the long absolute path is no longer necessary. For merovingian this wasn't much of a problem because it already chdirs into the dbfarm, but for monetdb it required a chdir to dbfarm first. It only does now if the connection to use is a UNIX domain socket. Since all actions are done remotely, the working directory for monetdb doesn't matter at all. Solaris: defined sun_path = 108 max sun_path = 1024 FreeBSD 8.0: defined sun_path = 104 max sun_path = 254 Fedora 11: defined sun_path = 108 max sun_path = 108 AIX 6.1: defined sun_path = 1023 max sun_path = 1023 diffs (120 lines): diff -r a6e4cb66bb13 -r 986a0834e2fe sql/src/backends/monet5/merovingian/ChangeLog.Jun2010 --- a/sql/src/backends/monet5/merovingian/ChangeLog.Jun2010 Mon Jul 26 11:19:01 2010 +0200 +++ b/sql/src/backends/monet5/merovingian/ChangeLog.Jun2010 Mon Jul 26 11:38:04 2010 +0200 @@ -1,6 +1,10 @@ # ChangeLog file for sql/src/backends/monet5/merovingian # This file is updated with mchangelog + 26 Jul 2010; Fabian Groffen <fab...@cwi.nl> merovingian.c, monetdb.c: + On installs with (very) long prefixes, the UNIX domain sockets could get + truncated, causing merovingian to become unavailable to monetdb and mclient. + 21 Jul 2010; Fabian Groffen <fab...@cwi.nl> merovingian.c: Really shutdown when an argument to merovingian was given, instead of ending up in some inconsistent state. This solves all weird behaviour diff -r a6e4cb66bb13 -r 986a0834e2fe sql/src/backends/monet5/merovingian/merovingian.c --- a/sql/src/backends/monet5/merovingian/merovingian.c Mon Jul 26 11:19:01 2010 +0200 +++ b/sql/src/backends/monet5/merovingian/merovingian.c Mon Jul 26 11:38:04 2010 +0200 @@ -425,8 +425,9 @@ str dbfarm, pidfilename; str p, prefix; FILE *cnf = NULL, *pidfile = NULL; + char *control_usock; + char *mapi_usock; char buf[1024]; - char bufu[1024]; dpair d = NULL; int pfd[2]; int retfd = -1; @@ -593,7 +594,7 @@ } /* where is the mserver5 binary we fork on demand? */ - snprintf(buf, 1023, "%s/bin/mserver5", prefix); + snprintf(buf, sizeof(buf), "%s/bin/mserver5", prefix); _mero_mserver = alloca(sizeof(char) * (strlen(buf) + 1)); memcpy(_mero_mserver, buf, strlen(buf) + 1); /* exit early if this is not going to work well */ @@ -912,20 +913,20 @@ Mfprintf(stdout, "monitoring dbfarm %s\n", dbfarm); SABAOTHinit(dbfarm, NULL); + GDKfree(dbfarm); /* set up control channel path */ - snprintf(buf, 1024, "%s/.merovingian_control", dbfarm); - unlink(buf); - snprintf(bufu, 1024, "%s/mapi_socket", dbfarm); - unlink(bufu); - GDKfree(dbfarm); + control_usock = ".merovingian_control"; + unlink(control_usock); + mapi_usock = "mapi_socket"; + unlink(mapi_usock); /* open up connections */ if ( (e = openConnectionTCP(&sock, _mero_port, stdout)) == NO_ERR && - (e = openConnectionUNIX(&socku, bufu, 0, stdout)) == NO_ERR && + (e = openConnectionUNIX(&socku, mapi_usock, 0, stdout)) == NO_ERR && (e = openConnectionUDP(&usock, discoveryport)) == NO_ERR && - (e = openConnectionUNIX(&unsock, buf, S_IRWXO, _mero_ctlout)) == NO_ERR && + (e = openConnectionUNIX(&unsock, control_usock, S_IRWXO, _mero_ctlout)) == NO_ERR && (_mero_controlport == 0 || (e = openConnectionTCP(&csock, _mero_controlport, _mero_ctlout)) == NO_ERR) ) { @@ -992,12 +993,12 @@ } /* control channel is already closed at this point */ - if (unlink(buf) == -1) + if (unlink(control_usock) == -1) Mfprintf(stderr, "unable to unlink control socket '%s': %s\n", - buf, strerror(errno)); - if (unlink(bufu) == -1) + control_usock, strerror(errno)); + if (unlink(mapi_usock) == -1) Mfprintf(stderr, "unable to unlink mapi socket '%s': %s\n", - bufu, strerror(errno)); + mapi_usock, strerror(errno)); if (e != NO_ERR) { /* console */ diff -r a6e4cb66bb13 -r 986a0834e2fe sql/src/backends/monet5/merovingian/monetdb.c --- a/sql/src/backends/monet5/merovingian/monetdb.c Mon Jul 26 11:19:01 2010 +0200 +++ b/sql/src/backends/monet5/merovingian/monetdb.c Mon Jul 26 11:38:04 2010 +0200 @@ -76,7 +76,6 @@ static str dbfarm = NULL; static int mero_running = 0; -static char mero_control[8096]; static char *mero_host = NULL; static int mero_port = -1; static char *mero_pass = NULL; @@ -1366,10 +1365,6 @@ mero_running = 0; } - /* set path to control channel */ - snprintf(mero_control, sizeof(mero_control), - "%s/.merovingian_control", dbfarm); - /* Start handling the arguments. * monetdb [monetdb_options] command [options] [database [...]] * this means we first scout for monetdb_options which stops as soon @@ -1487,8 +1482,13 @@ } /* use UNIX socket if no hostname given */ - if (mero_host == NULL) - mero_host = mero_control; + if (mero_host == NULL) { + /* avoid overrunning the sun_path buffer by moving into the + * directory where the UNIX socket resides (sun_path is + * typically around 108 chars long) */ + chdir(dbfarm); + mero_host = ".merovingian_control"; + } /* handle regular commands */ if (strcmp(argv[i], "create") == 0) { _______________________________________________ Checkin-list mailing list Checkin-list@monetdb.org http://mail.monetdb.org/mailman/listinfo/checkin-list