Hi Developers, i've been prooving the dbpool of kannel in the following scenario and i've found some problems
static DBPool *pool3 = NULL; //GLOBAL //DATA BASE INIT void voDBInitalization() { CfgGroup *grp; Octstr *host, *username, *password, *database; long port; grp = cfg_get_single_group(cfg, octstr_imm("Database")); if((host = cfg_get(grp, octstr_imm("Host")))==NULL) panic(0, "Host"); if((username = cfg_get(grp, octstr_imm("User")))==NULL) panic(0, "User"); if((password = cfg_get(grp, octstr_imm("Password")))==NULL) panic(0, "passl"); if((database = cfg_get(grp, octstr_imm("DBName")))==NULL) panic(0, "db"); if (cfg_get_integer(&port, grp, octstr_imm("Port")) == -1) panic(0, "port"); db_conf = gw_malloc(sizeof(DBConf)); gw_assert(db_conf != NULL); db_conf->mysql = gw_malloc(sizeof(MySQLConf)); gw_assert(db_conf->mysql != NULL); db_conf->mysql->host = host; db_conf->mysql->port = port; db_conf->mysql->username = username; db_conf->mysql->password = password; db_conf->mysql->database = database; pool = dbpool_create(DBPOOL_MYSQL, db_conf, 2); gw_assert(pool != NULL); } //MAIN int main (){ threads[j++] = gwthread_create(thread1,&stParam); threads[j++] = gwthread_create(thread2,&stParam); for (i = 0; i < j; ++i) gwthread_join(threads[i]); } thread1 and thread2 share the pool and try the query when dbpool_check returns >=1. Both threads check the pool with dbpool_check(pool) and its works correctly a few minutes but then the program throw panic because the function dbpool_check call pconn = gwlist_get(p->pool, i); AND THE FOLLOWING CONDITION DOESN'T MATCH gw_assert(pos < list->len); in gwlist_get I supose something like this is happening: one thread get the len of the pool and then the other deletes one element when the dbpool_check try to re-establish some connection, so, the first thread has a inconsitent len of the pool. i hope that i have explained the problem in the right way and sorry for the mistakes. -- Esteban L. Cacavelos de Amoriza Cel: 0981 220 429