aboutsummaryrefslogtreecommitdiff
path: root/modules/mysql/mysql.c
diff options
context:
space:
mode:
Diffstat (limited to 'modules/mysql/mysql.c')
-rw-r--r--modules/mysql/mysql.c37
1 files changed, 22 insertions, 15 deletions
diff --git a/modules/mysql/mysql.c b/modules/mysql/mysql.c
index 3d24542..315dd8b 100644
--- a/modules/mysql/mysql.c
+++ b/modules/mysql/mysql.c
@@ -33,5 +33,4 @@
-#define MDB_INIT 0x01
-#define MDB_OPEN 0x02
-#define MDB_DEFDB 0x04
+#define MDB_OPEN 0x01
+#define MDB_DEFDB 0x02
@@ -92,8 +91,2 @@ opendb(struct mod_mysql_db *db)
- if (!(db->flags & MDB_INIT)) {
- smap_error("%s: module settings do not include opendb flag",
- db->name);
- return 1;
- }
-
if (!mysql_init(&db->mysql)) {
@@ -158,2 +151,17 @@ freedb(struct mod_mysql_db *db)
static int
+dbdeclared(struct mod_mysql_db *db)
+{
+ return db->config_file ||
+ db->config_group ||
+ db->ssl_ca ||
+ db->host ||
+ db->user ||
+ db->password ||
+ db->database ||
+ db->port ||
+ db->socket;
+}
+
+
+static int
mod_init(int argc, char **argv)
@@ -161,3 +169,2 @@ mod_init(int argc, char **argv)
int rc;
- int opendb = 0;
@@ -165,4 +172,2 @@ mod_init(int argc, char **argv)
struct smap_option init_option[] = {
- { SMAP_OPTSTR(open), smap_opt_bool,
- &opendb },
{ SMAP_OPTSTR(config-file), smap_opt_string,
@@ -199,4 +204,3 @@ mod_init(int argc, char **argv)
return rc;
- if (opendb)
- def_db.flags = MDB_INIT;
+ def_db.flags = 0;
return 0;
@@ -264,3 +268,3 @@ mod_init_db(const char *dbid, int argc, char **argv)
- db->flags = MDB_INIT | flags;
+ db->flags = flags;
db->name = dbid;
@@ -280,2 +284,5 @@ mod_init_db(const char *dbid, int argc, char **argv)
+ if (!dbdeclared(db))
+ db->flags |= MDB_DEFDB;
+
return (smap_database_t) db;

Return to:

Send suggestions and report system problems to the System administrator.