Ejemplo n.º 1
0
static int mi_child_init(void)
{
	if(ds_db_url.s)
		return ds_connect_db();
	return 0;

}
Ejemplo n.º 2
0
static int ds_child_init(int rank)
{
	/* we need DB connection from the timer procs (for the flushing) 
	 * and from the main proc (for final flush on shutdown) */
	if ( (process_no==0 || rank==PROC_TIMER) && ds_db_url.s)
		return ds_connect_db();
	return 0;
}
Ejemplo n.º 3
0
static int mi_child_init(void)
{
	ds_partition_t *partition_it;

	for (partition_it = partitions; partition_it;
			partition_it = partition_it->next)

		if (partition_it->db_url.s)
			if (ds_connect_db(partition_it) != 0)
				return -1;

	return 0;
}
Ejemplo n.º 4
0
/*initialize and verify DB stuff*/
int init_ds_db(void)
{
	int _ds_table_version;
	int ret;

	if(ds_table_name.s == 0)
	{
		LM_ERR("invalid database name\n");
		return -1;
	}
	
	/* Find a database module */
	if (db_bind_mod(&ds_db_url, &ds_dbf) < 0)
	{
		LM_ERR("Unable to bind to a database driver\n");
		return -1;
	}
	
	if(ds_connect_db()!=0){
		
		LM_ERR("unable to connect to the database\n");
		return -1;
	}
	
	_ds_table_version = db_table_version(&ds_dbf, ds_db_handle, &ds_table_name);
	if (_ds_table_version < 0) 
	{
		LM_ERR("failed to query table version\n");
		return -1;
	} else if (_ds_table_version != DS_TABLE_VERSION) {
		LM_ERR("invalid table version (found %d , required %d)\n"
			"(use opensipsdbctl reinit)\n",
			_ds_table_version, DS_TABLE_VERSION );
		return -1;
	}

	ret = ds_load_db();

	ds_disconnect_db();

	return ret;
}
Ejemplo n.º 5
0
static int ds_child_init(int rank)
{
	/* we need DB connection from the worker procs (for the flushing)
	 * and from the main proc (for final flush on shutdown) */
	if ( rank>=PROC_MAIN ) {

		ds_partition_t *partition_it;

		for (partition_it = partitions; partition_it;
				partition_it = partition_it->next){

			if (partition_it->db_url.s)
				if (ds_connect_db(partition_it) != 0) {
					LM_ERR("failed to do DB connect\n");
					return -1;
				}
		}

	}
	return 0;
}