]> the.earth.li Git - onak.git/commitdiff
Exit on failure to initialise a dynamic DB backend
authorJonathan McDowell <noodles@earth.li>
Wed, 31 Jul 2019 18:08:37 +0000 (19:08 +0100)
committerJonathan McDowell <noodles@earth.li>
Wed, 31 Jul 2019 18:08:37 +0000 (19:08 +0100)
The dynamic DB backend does a lot of checks to ensure it can load the
requested backend successfully, but didn't actually check that it
initialised correctly. Bomb out with a graceful error message if this
happens rather than leading the caller to think everything is ok.

keydb_dynamic.c

index 9e4e3bcb7585e27decf07aa2a8ca22905d0a0573..ef42fbe35406977deb152610eceab0032bda850c 100644 (file)
@@ -291,11 +291,20 @@ struct onak_dbctx *keydb_dynamic_init(struct onak_db_config *dbcfg,
                soname = NULL;
                exit(EXIT_FAILURE);
        }
-       free(soname);
-       soname = NULL;
 
        privctx->loadeddbctx = backend_init(dbcfg, readonly);
 
+       if (privctx->loadeddbctx == NULL) {
+               logthing(LOGTHING_CRITICAL,
+                               "Failed to initialise dynamic backend: %s",
+                               soname);
+               free(soname);
+               soname = NULL;
+               exit(EXIT_FAILURE);
+       }
+       free(soname);
+       soname = NULL;
+
        if (privctx->loadeddbctx != NULL) {
                dbctx->cleanupdb = dynamic_cleanupdb;
                dbctx->starttrans = dynamic_starttrans;