Don't detach unconditionally after pthread_join()

merge-requests/1/head
Olaf Meeuwissen 2015-09-12 15:20:21 +09:00 zatwierdzone przez m. allan noah
rodzic 20a0ed547e
commit eb54dbf200
1 zmienionych plików z 9 dodań i 5 usunięć

Wyświetl plik

@ -512,11 +512,15 @@ sanei_thread_waitpid( SANE_Pid pid, int *status )
DBG(2, "* result = %d (%p)\n", stat, (void*)status );
result = pid;
}
/* call detach in any case to make sure that the thread resources
* will be freed, when the thread has terminated
*/
DBG(2, "* detaching thread(%ld)\n", pid );
pthread_detach((pthread_t)pid);
if ( EDEADLK == rc ) {
if ( (pthread_t)pid != pthread_self() ) {
/* call detach in any case to make sure that the thread resources
* will be freed, when the thread has terminated
*/
DBG(2, "* detaching thread(%ld)\n", pid );
pthread_detach((pthread_t)pid);
}
}
if (status)
*status = stat;