From 58912f68c2489bcee787599837447e0d64dfd61a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Frings-F=C3=BCrst?= Date: Wed, 24 May 2017 21:03:56 +0200 Subject: New upstream version 1.0.27 --- sanei/sanei_thread.c | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) (limited to 'sanei/sanei_thread.c') diff --git a/sanei/sanei_thread.c b/sanei/sanei_thread.c index 8db4a21..fcf52c1 100644 --- a/sanei/sanei_thread.c +++ b/sanei/sanei_thread.c @@ -71,9 +71,6 @@ #if !defined USE_PTHREAD && !defined HAVE_OS2_H && !defined __BEOS__ # include #endif -#if defined USE_PTHREAD -# include -#endif #define BACKEND_NAME sanei_thread /**< name of this module for debugging */ @@ -135,9 +132,9 @@ sanei_thread_set_invalid( SANE_Pid *pid ) /* Return if PID is a valid PID or not. */ SANE_Bool -sanei_thread_is_invalid( SANE_Pid pid ) +sanei_thread_is_valid( SANE_Pid pid ) { - SANE_Bool rc = SANE_FALSE; + SANE_Bool rc = SANE_TRUE; #ifdef WIN32 #ifdef WINPTHREAD_API @@ -145,10 +142,10 @@ sanei_thread_is_invalid( SANE_Pid pid ) #else if (pid.p == 0) #endif - rc = SANE_TRUE; + rc = SANE_FALSE; #else - if (pid == -1) - rc = SANE_TRUE; + if (pid == (SANE_Pid) -1) + rc = SANE_FALSE; #endif return rc; @@ -491,7 +488,7 @@ sanei_thread_waitpid( SANE_Pid pid, int *status ) #else int ls; #endif - SANE_Pid result; + SANE_Pid result = pid; int stat; stat = 0; -- cgit v1.2.3 From 1687222e1b9e74c89cafbb5910e72d8ec7bfd40f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Frings-F=C3=BCrst?= Date: Wed, 31 Jul 2019 16:59:49 +0200 Subject: New upstream version 1.0.28 --- sanei/sanei_thread.c | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) (limited to 'sanei/sanei_thread.c') diff --git a/sanei/sanei_thread.c b/sanei/sanei_thread.c index fcf52c1..f701423 100644 --- a/sanei/sanei_thread.c +++ b/sanei/sanei_thread.c @@ -115,20 +115,22 @@ sanei_thread_is_forked( void ) /* Use this to mark a SANE_Pid as invaild instead of marking with -1. */ +#ifdef USE_PTHREAD static void sanei_thread_set_invalid( SANE_Pid *pid ) { #ifdef WIN32 #ifdef WINPTHREAD_API - *pid = 0; + *pid = (pthread_t) 0; #else pid->p = 0; #endif #else - *pid = -1; + *pid = (pthread_t) -1; #endif } +#endif /* Return if PID is a valid PID or not. */ SANE_Bool @@ -162,12 +164,12 @@ sanei_thread_pid_to_long( SANE_Pid pid ) #ifdef WIN32 #ifdef WINPTHREAD_API - rc = pid; + rc = (long) pid; #else rc = pid.p; #endif #else - rc = pid; + rc = (long) pid; #endif return rc; @@ -225,7 +227,7 @@ sanei_thread_begin( int (*func)(void *args), void* args ) DBG( 1, "_beginthread() failed\n" ); return -1; } - + DBG( 2, "_beginthread() created thread %d\n", pid ); return pid; } @@ -282,7 +284,7 @@ sanei_thread_begin( int (*func)(void *args), void* args ) DBG( 1, "resume_thread() failed\n" ); return -1; } - + DBG( 2, "spawn_thread() created thread %d\n", pid ); return pid; } @@ -374,7 +376,7 @@ restore_sigpipe( void ) sigemptyset( &act.sa_mask ); act.sa_flags = 0; act.sa_handler = SIG_DFL; - + DBG( 2, "restoring SIGPIPE to SIG_DFL\n" ); sigaction( SIGPIPE, &act, NULL ); } @@ -443,7 +445,7 @@ sanei_thread_begin( int (func)(void *args), void* args ) } else DBG( 2, "pthread_create() created thread %ld\n", - (SANE_Pid)thread ); + sanei_thread_pid_to_long(thread) ); return (SANE_Pid)thread; #else @@ -458,7 +460,7 @@ sanei_thread_begin( int (func)(void *args), void* args ) /* run in child context... */ int status = func( args ); - + /* don't use exit() since that would run the atexit() handlers */ _exit( status ); } @@ -511,10 +513,11 @@ sanei_thread_waitpid( SANE_Pid pid, int *status ) } if ( EDEADLK == rc ) { if ( (pthread_t)pid != pthread_self() ) { - /* call detach in any case to make sure that the thread resources + /* 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 ); + DBG(2, "* detaching thread(%ld)\n", + sanei_thread_pid_to_long(pid) ); pthread_detach((pthread_t)pid); } } -- cgit v1.2.3