Changeset: b5f36b7500fe for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=b5f36b7500fe
Modified Files:
common/utils/msabaoth.c
common/utils/msabaoth.h
tools/merovingian/daemon/multiplex-funnel.c
Branch: default
Log Message:
reduced global variables
diffs (114 lines):
diff --git a/common/utils/msabaoth.c b/common/utils/msabaoth.c
--- a/common/utils/msabaoth.c
+++ b/common/utils/msabaoth.c
@@ -41,9 +41,9 @@
#endif
/** the directory where the databases are (aka dbfarm) */
-char *_sabaoth_internal_dbfarm = NULL;
+static char *_sabaoth_internal_dbfarm = NULL;
/** the database which is "active" */
-char *_sabaoth_internal_dbname = NULL;
+static char *_sabaoth_internal_dbname = NULL;
/** identifier of the current process */
static char *_sabaoth_internal_uuid = NULL;
@@ -119,6 +119,16 @@ msab_isuuid(const char *restrict s)
return hyphens == 4;
}
+void
+msab_dbnameinit(const char *dbname)
+{
+ if (dbname == NULL) {
+ _sabaoth_internal_dbname = NULL;
+ } else {
+ _sabaoth_internal_dbname = strdup(dbname);
+ }
+}
+
/**
* Initialises this Sabaoth instance to use the given dbfarm and dbname.
* dbname may be NULL to indicate that there is no active database. The
@@ -157,11 +167,7 @@ msab_init(const char *dbfarm, const char
len--;
}
- if (dbname == NULL) {
- _sabaoth_internal_dbname = NULL;
- } else {
- _sabaoth_internal_dbname = strdup(dbname);
- }
+ msab_dbnameinit(dbname);
/* clean out old UUID files in case the database crashed in a
* previous incarnation */
diff --git a/common/utils/msabaoth.h b/common/utils/msabaoth.h
--- a/common/utils/msabaoth.h
+++ b/common/utils/msabaoth.h
@@ -62,6 +62,7 @@ typedef struct Ssabuplog {
#endif
msab_export void msab_dbpathinit(const char *dbpath);
+msab_export void msab_dbnameinit(const char *dbname); /* switch dbname, used
by multiplex-funnel */
msab_export void msab_dbfarminit(const char *dbfarm);
msab_export char *msab_getDBfarm(char **ret);
msab_export char *msab_getDBname(char **ret);
diff --git a/tools/merovingian/daemon/multiplex-funnel.c
b/tools/merovingian/daemon/multiplex-funnel.c
--- a/tools/merovingian/daemon/multiplex-funnel.c
+++ b/tools/merovingian/daemon/multiplex-funnel.c
@@ -277,10 +277,6 @@ multiplexNotifyRemovedDB(const char *dat
/* coverity[leaked_storage] */
}
-/* ultra ugly, we peek inside Sabaoth's internals to update the uplog
- * file */
-extern char *_sabaoth_internal_dbname;
-
err
multiplexInit(char *name, char *pattern, FILE *sout, FILE *serr)
{
@@ -457,15 +453,14 @@ multiplexInit(char *name, char *pattern,
* internals -- we know dbname should be NULL, and hack it for the
* purpose of this moment, see also extern declaration before this
* function */
- _sabaoth_internal_dbname = name;
+ msab_dbnameinit(name);
if ((p = msab_registerStarting()) != NULL ||
(p = msab_registerStarted()) != NULL ||
(p = msab_marchScenario("mfunnel")) != NULL)
{
err em;
- _sabaoth_internal_dbname = NULL;
-
+ msab_dbnameinit(NULL);
Mfprintf(serr, "mfunnel: unable to startup %s: %s\n",
name, p);
em = newErr("cannot create funnel %s due to sabaoth: %s", name,
p);
@@ -473,8 +468,7 @@ multiplexInit(char *name, char *pattern,
return(em);
}
- _sabaoth_internal_dbname = NULL;
-
+ msab_dbnameinit(NULL);
return(NO_ERR);
}
@@ -509,13 +503,13 @@ multiplexDestroy(char *mp)
}
/* deregister from sabaoth, same hack alert as at Init */
- _sabaoth_internal_dbname = m->name;
+ msab_dbnameinit(m->name);
if ((msg = msab_registerStop()) != NULL ||
(msg = msab_wildRetreat()) != NULL) {
Mfprintf(stderr, "mfunnel: %s\n", msg);
free(msg);
}
- _sabaoth_internal_dbname = NULL;
+ msab_dbnameinit(NULL);
/* signal the thread to stop and cleanup */
m->shutdown = 1;
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list