Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

An improper locking due to the unreleased lock before program exit #6

Open
ycaibb opened this issue Sep 6, 2021 · 0 comments
Open

Comments

@ycaibb
Copy link

ycaibb commented Sep 6, 2021

Hi developers, in the below codes, the lock daemon could be not released before program's exit abort();. I think it is better to write MHD_ip_count_unlock (daemon); before the abort(); for better resource management and code symmetry. Thanks!

MHD_ip_count_lock (daemon);
/* Search for the IP address */
node = (void*)TFIND (&search_key, &daemon->per_ip_connection_count, MHD_ip_addr_compare);
/* Something's wrong if we couldn't find an IP address
* that was previously added */
if (!node)
{
#if HAVE_MESSAGES
MHD_DLOG (daemon,
"Failed to find previously-added IP address\n");
#endif
abort();
}
found_key = (struct MHD_IPCount*)*(void**)node;
/* Validate existing count for IP address */
if (found_key->count == 0)
{
#if HAVE_MESSAGES
MHD_DLOG (daemon,
"Previously-added IP address had 0 count\n");
#endif
abort();
}
/* Remove the node entirely if count reduces to 0 */
if (--found_key->count == 0)
{
TDELETE (found_key, &daemon->per_ip_connection_count, MHD_ip_addr_compare);
free (found_key);
}
MHD_ip_count_unlock (daemon);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant