]> the.earth.li Git - onak.git/blobdiff - keydb_dynamic.c
Exit on failure to initialise a dynamic DB backend
[onak.git] / keydb_dynamic.c
index 25a359aa9ecb548b2d25159c6ac474a5c623c543..ef42fbe35406977deb152610eceab0032bda850c 100644 (file)
@@ -13,8 +13,7 @@
  * more details.
  *
  * You should have received a copy of the GNU General Public License along with
- * this program; if not, write to the Free Software Foundation, Inc., 51
- * Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ * this program.  If not, see <https://www.gnu.org/licenses/>.
  */
 
 #include <dlfcn.h>
@@ -292,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;