Hi, developers:
If the pthread_create return 0,i.e., fails to create the thread, the function returns immediately with the lock mutex unreleased. It is in the test folder but still worth fixing for higher quality. Thank you for your checking.
The fix is to insert pthread_mutex_unlock(&mutex); before returning.
|
pthread_mutex_lock(&mutex); |
|
ret = pthread_create(&recv_thread, NULL, recv_fn, &rd); |
static int test(int buf_select, int no_buf_add, int iov_count)
{
...;
pthread_mutex_lock(&mutex);
rd.mutex = &mutex;
rd.buf_select = buf_select;
rd.no_buf_add = no_buf_add;
rd.iov_count = iov_count;
ret = pthread_create(&recv_thread, NULL, recv_fn, &rd);
if (ret) {
fprintf(stderr, "Thread create failed\n"); //pthread_mutex_unlock(&mutex);
return 1;
}
...;
}