First, thank you for your checking! The lock&global_alloc_free_lock is not released if the !alloc is satisfied. The fix is to insert pthread_mutex_unlock(&global_alloc_free_lock); before exit(1).
Note that it is not a very harmful bug( e.g., resource leak, deadlock) since the program exits and all of the program resources will be cleaned up by some common OS. However, other OS systems (e.g., embedded systems) do not automatically free some resources at the exit. It is a good manner for resource management. Adding the unlock statement adds symmetry, so the code looks better. Also, the debugger would not warn this case : )
First, thank you for your checking! The lock
&global_alloc_free_lock
is not released if the!alloc
is satisfied. The fix is to insertpthread_mutex_unlock(&global_alloc_free_lock);
before exit(1).Note that it is not a very harmful bug( e.g., resource leak, deadlock) since the program exits and all of the program resources will be cleaned up by some common OS. However, other OS systems (e.g., embedded systems) do not automatically free some resources at the exit. It is a good manner for resource management. Adding the unlock statement adds symmetry, so the code looks better. Also, the debugger would not warn this case : )
https://github.com/payden/libwebsock/blob/3c1615eeadb0b582b63851073bfe3e5132f31ebc/src/util.c#L78
Best,