add: DBG("DBT:dbt_cache_get_db: db already cached!\n");
context: dbt_cache_p dbt_cache_get_db(str *_s){	dbt_cache_p _dcache=NULL;;	if(!_cachesem || !_cachedb)	{		LOG(L_ERR, "DBT:dbt_cache_get_db:dbtext cache is not initialized!\n");		return NULL;	}	if(!_s || !_s->s || _s->len<=0)		return NULL;	DBG("DBT:dbt_cache_get_db: looking for db!\n");	lock_get(_cachesem);		_dcache = *_cachedb;	while(_dcache)	{		lock_get(&_dcache->sem);		if(_dcache->dbp)		{			if(_dcache->dbp->name.len==_s->len 					&& !strncasecmp(_dcache->dbp->name.s, _s->s, _s->len))			{				lock_release(&_dcache->sem);				goto done;			}		}		lock_release(&_dcache->sem);				_dcache = _dcache->next;	}	if(!dbt_is_database(_s))	{		LOG(L_ERR, "DBT:dbt_cache_get_db: database [%.*s] does not exists!\n", 				_s->len, _s->s);		goto done;	}	DBG("DBT:dbt_cache_get_db: new db!\n");		_dcache = (dbt_cache_p)shm_malloc(sizeof(dbt_cache_t));	if(!_dcache)	{		LOG(L_ERR, "DBT:dbt_cache_get_db: no memory for dbt_cache_t.\n");		goto done;	}		_dcache->dbp = (dbt_db_p)shm_malloc(sizeof(dbt_db_t));	if(!_dcache->dbp)	{		LOG(L_ERR, "DBT:dbt_cache_get_db: no memory for dbt_db_t!\n");		shm_free(_dcache);		goto done;	}	_dcache->dbp->name.s = (char*)shm_malloc(_s->len*sizeof(char));	if(!_dcache->dbp->name.s)	{		LOG(L_ERR, "DBT:dbt_cache_get_db: no memory for s!!\n");		shm_free(_dcache->dbp);		shm_free(_dcache);		_dcache = NULL;		goto done;	}		memcpy(_dcache->dbp->name.s, _s->s, _s->len);	_dcache->dbp->name.len = _s->len;	_dcache->dbp->tables = NULL;		if(!lock_init(&_dcache->sem))	{		LOG(L_ERR, "DBT:dbt_cache_get_db: no sems!\n");		shm_free(_dcache->dbp->name.s);		shm_free(_dcache->dbp);		shm_free(_dcache);		_dcache = NULL;		goto done;	}		_dcache->prev = NULL;	if(*_cachedb)	{		_dcache->next = *_cachedb;		(*_cachedb)->prev = _dcache;	}	else		_dcache->next = NULL;	*_cachedb = _dcache;done:	lock_release(_cachesem);	return _dcache;}