static int mod_init(void) { matrix_db_vars(); if (init_shmlock() != 0) return -1; if (matrix_db_init() != 0) return -1; if (matrix_db_open() != 0) return -1; if (init_matrix() != 0) return -1; matrix_db_close(); return 0; }
static void matrix_rpc_reload(rpc_t* rpc, void* c) { if (matrix_db_open() != 0) { rpc->fault(c, 500, "Failed to connect to db"); return; } if(db_reload_matrix() < 0) { rpc->fault(c, 500, "Reload failed"); } matrix_db_close(); }
/*! * Initialises the DB API, check the table version and closes the connection. * This should be called from the mod_init function. * * \return 0 means ok, -1 means an error occured. */ int matrix_db_init(void) { if (!matrix_db_url.s || !matrix_db_url.len) { LM_ERR("you have to set the db_url module parameter.\n"); return -1; } if (db_bind_mod(&matrix_db_url, &matrix_dbf) < 0) { LM_ERR("can't bind database module.\n"); return -1; } if ((matrix_dbh = matrix_dbf.init(&matrix_db_url)) == NULL) { LM_ERR("can't connect to database.\n"); return -1; } if ( (db_check_table_version(&matrix_dbf, matrix_dbh, &matrix_table, matrix_version) < 0) ) { LM_ERR("during table version check.\n"); matrix_db_close(); return -1; } matrix_db_close(); return 0; }
static int mod_init(void) { if(matrix_rpc_init()<0) { LM_ERR("failed to init RPC commands"); return -1; } if (init_shmlock() != 0) return -1; if (matrix_db_init() != 0) return -1; if (matrix_db_open() != 0) return -1; if (init_matrix() != 0) return -1; matrix_db_close(); return 0; }
static int mod_init(void) { if(register_mi_mod(exports.name, mi_cmds)!=0) { LM_ERR("failed to register MI commands\n"); return -1; } if(matrix_rpc_init()<0) { LM_ERR("failed to init RPC commands"); return -1; } if (init_shmlock() != 0) return -1; if (matrix_db_init() != 0) return -1; if (matrix_db_open() != 0) return -1; if (init_matrix() != 0) return -1; matrix_db_close(); return 0; }
static void mod_destroy(void) { destroy_matrix(); destroy_shmlock(); matrix_db_close(); }