Update of /cvsroot/monetdb/MonetDB5/src/mal
In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv14195/mal
Modified Files:
mal_sabaoth.mx mal_session.mx
Log Message:
Implemented maintenance mode, where users are no longer permitted to log
in. Merovingian and monetdb don't know about this mode yet, but since
they are prepared for this, they work fine with it.
Index: mal_sabaoth.mx
===================================================================
RCS file: /cvsroot/monetdb/MonetDB5/src/mal/mal_sabaoth.mx,v
retrieving revision 1.32
retrieving revision 1.33
diff -u -d -r1.32 -r1.33
--- mal_sabaoth.mx 28 Aug 2007 11:41:00 -0000 1.32
+++ mal_sabaoth.mx 28 Aug 2007 12:38:44 -0000 1.33
@@ -255,6 +255,7 @@
FILE *f;
str path = alloca(sizeof(char) * (PATHLENGTH + 1));
str tmp;
+ sabdb *stats;
(void)ret;
@@ -263,12 +264,19 @@
if ((f = fopen(path, "a")) != NULL) {
/* append to the file */
fprintf(f, "mapi%s:monetdb://%s:%i/\n", *ssl ? "s" : "", *host,
*port);
- /* (some) people tend to like (very) noisy programs, hence to
- * please them, announce that we're now available from outside
*/
- printf("# Listening for connection requests on
mapi%s:monetdb://%s:%i/\n",
- *ssl ? "s" : "", *host, *port);
(void)fflush(f);
(void)fclose(f);
+ /* (some) people tend to like (very) noisy programs, hence to
+ * please them, announce that we're now available from outside
*/
+ printf("# Listening for connection requests on "
+ "mapi%s:monetdb://%s:%i/\n", *ssl ? "s" : "",
*host, *port);
+ /* emit a warning if we are in maintenance mode */
+ rethrow("sabaoth.getMyStatus", tmp,
+ SABAOTHgetMyStatus(&stats));
+ if (stats->state == SABdbMaintenance)
+ fprintf(stderr, "#warning: database is running in "
+ "maintenance mode\n");
+ SABAOTHfreeStatus(&stats);
return(MAL_SUCCEED);
}
throw(IO, "sabaoth.marchConnection",
@@ -420,6 +428,13 @@
struct Ssabdb* next; /* next database */
} sabdb;
+mal_export str SABAOTHgetMyStatus(sabdb** ret);
[EMAIL PROTECTED]
+str SABAOTHgetMyStatus(sabdb** ret) {
+ return(SABAOTHgetStatus(ret, _sabaoth_internal_dbname));
+}
+
[EMAIL PROTECTED]
/* Caching strategies (might be nice) should create a new struct with
* the last modified time_t of the files involved, such that a stat is
* sufficient to see if reparsing is necessary. The gdk_lock always has
@@ -427,6 +442,7 @@
*/
mal_export str SABAOTHgetStatus(sabdb** ret, str dbname);
+#define MAINTENANCEFILE ".maintenance"
@c
/**
*/
@@ -522,6 +538,8 @@
* running
* - to distinguish between a crash and proper shutdown, consult
* the uplog
+ * the existance of the maintenance file overrules any check and
+ * puts the server in maintenance mode
*/
snprintf(buf, PATHLENGTH, "%s/%s/%s", path, e->d_name,
".gdk_lock");
fd = MT_lockf(buf, F_TLOCK, 4, 1);
@@ -561,6 +579,12 @@
if (fd >= 0)
close(fd);
}
+ snprintf(buf, PATHLENGTH, "%s/%s/%s", path, e->d_name,
MAINTENANCEFILE);
+ f = fopen(buf, "r");
+ if (f != NULL) {
+ fclose(f);
+ sdb->state = SABdbMaintenance;
+ }
}
(void) closedir(d);
Index: mal_session.mx
===================================================================
RCS file: /cvsroot/monetdb/MonetDB5/src/mal/mal_session.mx,v
retrieving revision 1.140
retrieving revision 1.141
diff -u -d -r1.140 -r1.141
--- mal_session.mx 16 Aug 2007 20:18:27 -0000 1.140
+++ mal_session.mx 28 Aug 2007 12:38:44 -0000 1.141
@@ -240,7 +240,7 @@
*s = 0;
}
- if (database && database[0] != '\0' &&
+ if (database != NULL && database[0] != '\0' &&
strcmp(database, GDKgetenv("gdk_dbname")) != 0)
{
sabdb *stats;
@@ -282,6 +282,7 @@
} else {
str err;
oid uid;
+ sabdb *stats;
/* access control: verify the credentials supplied by the user,
* no need to check for database stuff, because that is done per
@@ -294,6 +295,31 @@
return;
}
+ err = SABAOTHgetMyStatus(&stats);
+ if (err != MAL_SUCCEED) {
+ /* this is kind of awful, but we need to get rid of this
+ * message */
+ fprintf(stderr, "!SABAOTHgetMyStatus: %s\n", err);
+ GDKfree(err);
+ GDKfree(command);
+ return;
+ }
+
+ if (stats->state == SABdbMaintenance) {
+ if (uid == 0) {
+ stream_printf(fout, "#server is running in "
+ "maintenance mode\n");
+ } else {
+ stream_printf(fout, "!server is running in "
+ "maintenance mode\n");
+ stream_flush(fout);
+ SABAOTHfreeStatus(&stats);
+ GDKfree(command);
+ return;
+ }
+ }
+ SABAOTHfreeStatus(&stats);
+
c = MCinitClient(uid, fin, fout);
if (c == NULL) {
stream_printf(fout, "!Out of client slots\n");
-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems? Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
_______________________________________________
Monetdb-checkins mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/monetdb-checkins