Skip to content

A potential error due to the unreleased lock #1267

@ycaibb

Description

@ycaibb

Dear developers: thank you for your checking. It seems the lock srv->main_thread->ownership is also not released if the ret==ret_ok .

ret_t
cherokee_server_close_connection (cherokee_server_t *srv, cherokee_thread_t *mythread, char *id_str)
{
	...;
	if (srv->main_thread != mythread) CHEROKEE_MUTEX_LOCK (&srv->main_thread->ownership);

	ret = thread_find_connection (srv->main_thread, id);
	if (ret == ret_ok) return ret; // the lock srv->main_thread->ownership is not released.

	if (srv->main_thread != mythread) CHEROKEE_MUTEX_UNLOCK (&srv->main_thread->ownership);

	list_for_each (t, &srv->thread_list) {
		cherokee_thread_t *thread = THREAD(t);

		if (thread != mythread) CHEROKEE_MUTEX_LOCK (&thread->ownership);

		ret = thread_find_connection (thread, id);

		if (thread != mythread) CHEROKEE_MUTEX_UNLOCK (&thread->ownership);

		if (ret == ret_ok) return ret;
	}

	return ret_not_found;
}

Best,

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions