-
Notifications
You must be signed in to change notification settings - Fork 27
Open
Description
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!
libmicrohttpd/src/daemon/daemon.c
Lines 333 to 367 in 61ce9c1
| 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); |
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels