-
Notifications
You must be signed in to change notification settings - Fork 90
Open
Description
Hi, developers, a small error (could be harmless) happen when the program exit with the lock &init_mutex unreleased. The fix is to insert pthread_mutex_unlock(&init_mutex); before exit(0). Could be fixed for high code quality. Thank you!
postgres-x2/src/test/thread/thread_test.c
Line 156 in 2a845c3
| pthread_mutex_lock(&init_mutex); |
int
main(int argc, char *argv[])
{
...;
/* Hold lock until we are ready for the child threads to exit. */
pthread_mutex_lock(&init_mutex);
rc = pthread_create(&thread1, NULL, (void *(*) (void *)) func_call_1, NULL);
if (rc != 0)
{
fprintf(stderr, "Failed to create thread 1: %s **\nexiting\n",
strerror(errno));
exit(1); // exit without releasing the lock
}
rc = pthread_create(&thread2, NULL, (void *(*) (void *)) func_call_2, NULL);
if (rc != 0)
{
/*
* strerror() might not be thread-safe, and we already spawned thread
* 1 that uses it, so avoid using it.
*/
fprintf(stderr, "Failed to create thread 2 **\nexiting\n");
exit(1); // exit without releasing the lock
}
...;
}
Best,
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels