cherokee/webserver

A locking issue in cherokee_server_free

ryancaicse opened this issue · 4 comments

Hi, there is only an unlocking in the loop, should it be a bug?

webserver/cherokee/server.c

Lines 266 to 269 in 5b1dbdb

list_for_each (i, &srv->thread_list) {
THREAD(i)->exit = true;
CHEROKEE_MUTEX_UNLOCK (&srv->listeners_mutex);
}

It may be, at this point I don't understand the code here. Did this produce a hang or crash at your side?

Hi, I guess, the lock is supposed to protect the THREAD(i)->exit = true; from races. May be there is a missing CHEROKEE_MUTEX_LOCK.

I just looked through the code (thread.c) to see what is is used for there. But I wonder if this is actually the way to unlock what has been locked there.

@skinkie It seems, in this loop, an identical lock is released multiple times rather than releasing different indexed locks. Thus, it is very likely a bug.

I also tried to investigate the reason. However, I could not find the possible held lock at that program point. I think it is more likely that the lock is supposed to protect the THREAD(i)->exit = true; from races and there is a missing CHEROKEE_MUTEX_LOCK.