[sr-dev] shm_lock in free_cell()

Miklos Tirpak miklos at iptel.org
Thu Sep 10 18:42:27 CEST 2009


Hi Jan,

when free_cell() frees the memory of a transaction the shm memory lock 
is already held:

shm_lock();
...
/* callbacks */
for( cbs=(struct tm_callback*)dead_cell->tmcb_hl.first ; cbs ; ) {
	cbs_tmp = cbs;
	cbs = cbs->next;
	if (cbs_tmp->release) {
		cbs_tmp->release(cbs_tmp->param);
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
I think this can cause a dead-lock because the release function is not 
aware of the state of the shm mem lock.


	}
	shm_free_unsafe( cbs_tmp );
}

I saw that you have added this function call, but I cannot found any 
customer of this function in the repository, so I do not know whether 
the cb functions use safe or unsafe shm_free(). Do you know anything 
about this?

I recently added another place where this cb is called from (without 
locking), hence I think it would be better to move this outside of the 
shm mem lock to be on the safe side.

http://git.sip-router.org/cgi-bin/gitweb.cgi?p=sip-router;a=commitdiff;h=657f117b853f8a33677ad0f4ffb482e6e25296fc

Thanks,
Miklos



More information about the sr-dev mailing list