int init_reg_db(const str *db_url) { /* Find a database module */ if (db_bind_mod(db_url, ®_dbf) < 0) { LM_ERR("Unable to bind to a database driver\n"); return -1; } if (connect_reg_db(db_url)!=0){ LM_ERR("unable to connect to the database\n"); return -1; } if(db_check_table_version(®_dbf, reg_db_handle, ®_table_name, REG_TABLE_VERSION) < 0) { LM_ERR("error during table version check.\n"); return -1; } /* Load registrants into the primary list */ if(load_reg_info_from_db(0) !=0){ LM_ERR("unable to load the registrant data\n"); return -1; } reg_dbf.close(reg_db_handle); reg_db_handle = NULL; return 0; }
static int child_init(int rank) { if (db_url.s != NULL && connect_reg_db(&db_url)) { LM_ERR("failed to connect to db (rank=%d)\n",rank); return -1; } return 0; }