[sr-dev] [kamailio/kamailio] the recursive lock of tm module is not safe? (Issue #3083)
progromm
notifications at github.com
Wed Apr 13 12:09:00 CEST 2022
### Description
See `lock_hash` in `h_table.c`:
```C
void lock_hash(int i)
{
int mypid;
mypid = my_pid();
if (likely(atomic_get(&_tm_table->entries[i].locker_pid) != mypid)) {
lock(&_tm_table->entries[i].mutex);
atomic_set(&_tm_table->entries[i].locker_pid, mypid);
} else {
/* locked within the same process that called us*/
_tm_table->entries[i].rec_lock_level++;
}
}
```
Flowing lines of code do not guarantee atomicity and I think it is not safe:
* atomic_get(&_tm_table->entries[i].locker_pid) != mypid
* lock(&_tm_table->entries[i].mutex)
* atomic_set(&_tm_table->entries[i].locker_pid, mypid)
Would you mind solving my confusion?
--
Reply to this email directly or view it on GitHub:
https://github.com/kamailio/kamailio/issues/3083
You are receiving this because you are subscribed to this thread.
Message ID: <kamailio/kamailio/issues/3083 at github.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.kamailio.org/pipermail/sr-dev/attachments/20220413/6348dc10/attachment.htm>
More information about the sr-dev
mailing list