Changeset: 246856d3a332 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=246856d3a332
Modified Files:
gdk/gdk_posix.mx
monetdb5/Makefile.ag
monetdb5/conf/Makefile.ag
monetdb5/conf/monetdb5.conf.5
monetdb5/conf/monetdb5.conf.in
monetdb5/mal/Makefile.ag
monetdb5/mal/mal_sabaoth.mx
monetdb5/misc/Makefile.ag
monetdb5/misc/monetdb5.conf.5
monetdb5/misc/monetdb5.conf.in
monetdb5/misc/msabaoth.c
monetdb5/misc/msabaoth.h
monetdb5/modules/mal/Makefile.ag
monetdb5/optimizer/Makefile.ag
monetdb5/scheduler/Makefile.ag
monetdb5/tools/Makefile.ag
sql/backends/monet5/Makefile.ag
sql/backends/monet5/merovingian/client/Makefile.ag
sql/backends/monet5/merovingian/client/monetdb.c
sql/backends/monet5/merovingian/daemon/Makefile.ag
sql/backends/monet5/merovingian/daemon/client.c
sql/backends/monet5/merovingian/daemon/client.h
sql/backends/monet5/merovingian/daemon/connections.c
sql/backends/monet5/merovingian/daemon/controlrunner.c
sql/backends/monet5/merovingian/daemon/discoveryrunner.c
sql/backends/monet5/merovingian/daemon/discoveryrunner.h
sql/backends/monet5/merovingian/daemon/forkmserver.c
sql/backends/monet5/merovingian/daemon/forkmserver.h
sql/backends/monet5/merovingian/daemon/handlers.c
sql/backends/monet5/merovingian/daemon/merovingian.c
sql/backends/monet5/merovingian/daemon/merovingian.h
sql/backends/monet5/merovingian/daemon/multiplex-funnel.c
sql/backends/monet5/merovingian/daemon/multiplex-funnel.h
sql/backends/monet5/merovingian/daemon/peering.c
sql/backends/monet5/merovingian/daemon/proxy.c
sql/backends/monet5/merovingian/utils/Makefile.ag
sql/backends/monet5/merovingian/utils/database.c
sql/backends/monet5/merovingian/utils/database.h
sql/backends/monet5/merovingian/utils/properties.c
sql/backends/monet5/merovingian/utils/utils.c
sql/backends/monet5/merovingian/utils/utils.h
Branch: default
Log Message:
sabaoth: detangle from M5 and GDK
Moved mal_sabaoth to msabaoth, made sure this is compiled first thing,
without any dependencies on GDK-memory functions. At the same time,
stripped merovingian and friends from any M5 and GDK references.
diffs (truncated from 4493 to 300 lines):
diff --git a/gdk/gdk_posix.mx b/gdk/gdk_posix.mx
--- a/gdk/gdk_posix.mx
+++ b/gdk/gdk_posix.mx
@@ -57,6 +57,8 @@
#include <winsock.h> /* for timeval */
#endif
+#include "gdk_system.h" /* gdk_export */
+
#ifdef NATIVE_WIN32
#include <io.h>
#include <direct.h>
diff --git a/monetdb5/Makefile.ag b/monetdb5/Makefile.ag
--- a/monetdb5/Makefile.ag
+++ b/monetdb5/Makefile.ag
@@ -15,7 +15,11 @@
# Copyright August 2008-2011 MonetDB B.V.
# All Rights Reserved.
-SUBDIRS = mal modules optimizer scheduler tools extras conf
+# misc: stuff that can be built without deps, but others may depend on
+# mal, modules, optimizer, scheduler: the main libmonetdb5 body, needs misc
+# tools: builds libmonetdb5 from mal, modules, optimizer, scheduler
+# extras: builds optional/separate libraries that require libmonetdb5
+SUBDIRS = misc mal modules optimizer scheduler tools extras
EXTRA_DIST = RunMtest.in \
RunMtest.bat.in RunMapprove.in RunMapprove.bat.in \
diff --git a/monetdb5/mal/Makefile.ag b/monetdb5/mal/Makefile.ag
--- a/monetdb5/mal/Makefile.ag
+++ b/monetdb5/mal/Makefile.ag
@@ -15,7 +15,8 @@
# Copyright August 2008-2011 MonetDB B.V.
# All Rights Reserved.
-INCLUDES = ../../common/options \
+INCLUDES = ../misc \
+ ../../common/options \
../../common/stream \
../../clients/mapilib \
../../gdk \
diff --git a/monetdb5/mal/mal_sabaoth.mx b/monetdb5/mal/mal_sabaoth.mx
--- a/monetdb5/mal/mal_sabaoth.mx
+++ b/monetdb5/mal/mal_sabaoth.mx
@@ -36,6 +36,7 @@
#include <mal.h>
#include <mal_exception.h>
+#include <msabaoth.h>
@-
@c
@@ -57,47 +58,15 @@
#define close _close
#endif
-/** the directory where the databases are (aka dbfarm) */
-str _sabaoth_internal_dbfarm = NULL;
-/** the database which is "active" */
-str _sabaoth_internal_dbname = NULL;
-
-static str getFarmPath(str *ret, size_t size, str extra) {
- if (_sabaoth_internal_dbfarm == NULL)
- throw(MAL, "sabaoth.assert", SABAOTH_NOT_INITIALIZED);
-
- if (extra == NULL) {
- snprintf(*ret, size, "%s", _sabaoth_internal_dbfarm);
- } else {
- snprintf(*ret, size, "%s%c%s", _sabaoth_internal_dbfarm,
DIR_SEP, extra);
- }
-
- return(MAL_SUCCEED);
+inline static char *
+fromMallocToGDK(char *val)
+{
+ char *ret = GDKstrdup(val);
+ free(val);
+ return(ret);
}
-static str getDBPath(str *ret, size_t size, str extra) {
- if (_sabaoth_internal_dbfarm == NULL)
- throw(MAL, "sabaoth.assert", SABAOTH_NOT_INITIALIZED);
- if (_sabaoth_internal_dbname == NULL)
- throw(MAL, "sabaoth.assert", SABAOTH_USE_RESTRICTION);
-
- if (extra == NULL) {
- snprintf(*ret, size, "%s%c%s",
- _sabaoth_internal_dbfarm,
- DIR_SEP,
- _sabaoth_internal_dbname);
- } else {
- snprintf(*ret, size, "%s%c%s%c%s",
- _sabaoth_internal_dbfarm,
- DIR_SEP,
- _sabaoth_internal_dbname,
- DIR_SEP,
- extra);
- }
-
- return(MAL_SUCCEED);
-}
-
+#define excFromMem(TPE, WHRE, X) { str _me = createException(TPE, WHRE,
"%s", X); free(X); return(_me); }
@h
mal_export void SABAOTHinit(str dbfarm, str dbname);
@c
@@ -107,33 +76,7 @@
* arguments are copied for internal use.
*/
void SABAOTHinit(str dbfarm, str dbname) {
- size_t len;
-
- assert(dbfarm != NULL);
-
- if (_sabaoth_internal_dbfarm != NULL)
- GDKfree(_sabaoth_internal_dbfarm);
- if (_sabaoth_internal_dbname != NULL)
- GDKfree(_sabaoth_internal_dbname);
-
- len = strlen(dbfarm);
- _sabaoth_internal_dbfarm = GDKstrdup(dbfarm);
- /* remove trailing slashes, newlines and spaces */
- len--;
- while (len > 0 && (
- _sabaoth_internal_dbfarm[len] == '/' ||
- _sabaoth_internal_dbfarm[len] == '\n' ||
- _sabaoth_internal_dbfarm[len] == ' '))
- {
- _sabaoth_internal_dbfarm[len] = '\0';
- len--;
- }
-
- if (dbname == NULL) {
- _sabaoth_internal_dbname = NULL;
- } else {
- _sabaoth_internal_dbname = GDKstrdup(dbname);
- }
+ msab_init(dbfarm, dbname);
}
@h
@@ -144,9 +87,11 @@
* exception if not initialised.
*/
str SABAOTHgetDBfarm(str *ret) {
- if (_sabaoth_internal_dbfarm == NULL)
- throw(MAL, "sabaoth.assert", SABAOTH_NOT_INITIALIZED);
- *ret = GDKstrdup(_sabaoth_internal_dbfarm);
+ str dbfarm;
+ str err = msab_getDBfarm(&dbfarm);
+ if (err != NULL)
+ excFromMem(MAL, "sabaoth.getdbfarm", err);
+ *ret = fromMallocToGDK(dbfarm);
return(MAL_SUCCEED);
}
@@ -158,55 +103,28 @@
* exception if not initialised or dbname was set to NULL.
*/
str SABAOTHgetDBname(str *ret) {
- if (_sabaoth_internal_dbfarm == NULL)
- throw(MAL, "sabaoth.assert", SABAOTH_NOT_INITIALIZED);
- if (_sabaoth_internal_dbname == NULL)
- throw(MAL, "sabaoth.assert", SABAOTH_USE_RESTRICTION);
- *ret = GDKstrdup(_sabaoth_internal_dbname);
+ str dbname;
+ str err = msab_getDBname(&dbname);
+ if (err != NULL)
+ excFromMem(MAL, "sabaoth.getdbname", err);
+ *ret = fromMallocToGDK(dbname);
return(MAL_SUCCEED);
}
@h
mal_export str SABAOTHmarchScenario(int *ret, str *lang);
@c
-#define SCENARIOFILE ".scen"
/**
* Writes the given language to the scenarios file. If the file doesn't
* exist, it is created. Multiple invocations of this function for the
* same language are ignored.
*/
str SABAOTHmarchScenario(int *ret, str *lang) {
- FILE *f;
- str buf = alloca(sizeof(char) * 256); /* should be enough for now */
- size_t len;
- str path = alloca(sizeof(char) * (PATHLENGTH + 1));
- str tmp;
+ str err = msab_marchScenario(*lang);
+ if (err != NULL)
+ excFromMem(MAL, "sabaoth.marchscenario", err);
(void)ret;
-
- rethrow("sabaoth.marchScenario", tmp,
- getDBPath(&path, PATHLENGTH, SCENARIOFILE));
- if ((f = fopen(path, "a+")) != NULL) {
- if ((len = fread(buf, 1, 255, f)) > 0) {
- str p;
-
- buf[len] = '\0';
- /* find newlines and evaluate string */
- while ((p = strchr(buf, '\n')) != NULL) {
- *p = '\0';
- if (strcmp(buf, *lang) == 0) {
- (void)fclose(f);
- return(MAL_SUCCEED);
- }
- buf = p;
- }
- }
- /* append to the file */
- fprintf(f, "%s\n", *lang);
- (void)fflush(f);
- (void)fclose(f);
- return(MAL_SUCCEED);
- }
- throw(IO, "sabaoth.marchScenario", RUNTIME_FILE_NOT_FOUND ":%s", path);
+ return(MAL_SUCCEED);
}
@h
@@ -218,68 +136,16 @@
* removed.
*/
str SABAOTHretreatScenario(int *ret, str *lang) {
- FILE *f;
- str buf = alloca(sizeof(char) * 256); /* should be enough for now */
- size_t len;
- str path = alloca(sizeof(char) * (PATHLENGTH + 1));
- str tmp;
+ str err = msab_retreatScenario(*lang);
+ if (err != NULL)
+ excFromMem(MAL, "sabaoth.retreatscenario", err);
(void)ret;
-
- rethrow("sabaoth.retreatScenario", tmp,
- getDBPath(&path, PATHLENGTH, SCENARIOFILE));
- if ((f = fopen(path, "a+")) != NULL) {
- if ((len = fread(buf, 1, 255, f)) > 0) {
- str p;
- FILE *tmp = tmpfile();
- int written = 0;
-
- buf[len] = '\0';
- /* find newlines and evaluate string */
- while ((p = strchr(buf, '\n')) != NULL) {
- *p = '\0';
- if (strcmp(buf, *lang) != 0) {
- fprintf(tmp, "%s\n", buf);
- written = 1;
- }
- buf = p;
- }
- if (written != 0) {
- buf = alloca(sizeof(char) * 256);
- /* no idea how to "move" a file by it's fd
(sounds
- * impossible anyway) and tmpnam is so much "DO
NOT USE"
- * that I decided to just copy over the file
again... */
- rewind(f);
- fflush(tmp);
- rewind(tmp);
- len = fread(buf, 1, 256, tmp);
- if (fwrite(buf, 1, len, f) < len)
- throw(IO, "sabaoth.retreatScenario",
RUNTIME_STREAM_WRITE);
- fflush(f);
- fclose(f);
- fclose(tmp); /* this should remove it
automagically */
- return(MAL_SUCCEED);
- } else {
- (void)fclose(f);
- unlink(path);
- return(MAL_SUCCEED);
- }
- } else if (len == 0) {
- (void)fclose(f);
- unlink(path);
- return(MAL_SUCCEED);
- } else { /* some error */
- str err = strerror(errno);
- (void)fclose(f);
- throw(IO, "sabaoth.retreatScenario",
RUNTIME_STREAM_WRITE " %s",err);
- }
- }
- throw(IO, "sabaoth.retreatScenario", RUNTIME_FILE_NOT_FOUND ":%s",
path);
+ return(MAL_SUCCEED);
}
@h
mal_export str SABAOTHmarchConnection(int *ret, str *host, int *port);
@c
-#define CONNECTIONFILE ".conn"
/**
* Writes an URI to the connection file based on the given arguments.
* If the file doesn't exist, it is created. Multiple invocations of
@@ -288,50 +154,11 @@
* socket, in which case host must start with a '/'.
*/
str SABAOTHmarchConnection(int *ret, str *host, int *port) {
- FILE *f;
_______________________________________________
Checkin-list mailing list
[email protected]
http://mail.monetdb.org/mailman/listinfo/checkin-list