kopia lustrzana https://gitlab.com/sane-project/backends
Fix for bug #306751: sanei-thread with pthreads on 64 bit
rodzic
8d55281218
commit
d5ae0bbc3d
12
ChangeLog
12
ChangeLog
|
@ -1,3 +1,15 @@
|
|||
2008-05-15 Mattias Ellert <mattias.ellert@fysast.uu.se>
|
||||
* backend/agfafocus.h, backend/artec_eplus48u.c,
|
||||
backend/artec_eplus48u.h, backend/avision.h, backend/coolscan.h,
|
||||
backend/hp-handle.c, backend/hp3500.c, backend/microtek2.h,
|
||||
backend/mustek.c, backend/mustek.h, backend/pie.c, backend/pixma.c,
|
||||
backend/plustek-pp.h, backend/plustek.c, backend/plustek.h,
|
||||
backend/plustek_pp.c, backend/snapscan.c, backend/snapscan.h,
|
||||
backend/sp15c.h, backend/tamarack.h, backend/test.c, backend/test.h,
|
||||
backend/u12.c, backend/u12.h, backend/umax.c, backend/umax.h,
|
||||
include/sane/sanei_thread.h, sanei/sanei_thread.c:
|
||||
Fix for bug #306751: sanei-thread with pthreads on 64 bit
|
||||
|
||||
2008-04-12 Stéphane Voltz <stef.dev@free.fr>
|
||||
* backend/rts8891.c
|
||||
150/300 dpi mode fixes for 'XPA' sensor HP4470 models
|
||||
|
|
|
@ -120,7 +120,7 @@ typedef struct AgfaFocus_Scanner
|
|||
int lines_available; /* Lines in scanner memory */
|
||||
|
||||
int fd; /* SCSI filedescriptor */
|
||||
pid_t reader_pid; /* process id of reader */
|
||||
SANE_Pid reader_pid; /* process id of reader */
|
||||
int pipe; /* pipe to reader process */
|
||||
int reader_pipe; /* pipe from reader process */
|
||||
|
||||
|
|
|
@ -3478,7 +3478,7 @@ static SANE_Status
|
|||
do_cancel (Artec48U_Scanner * s, SANE_Bool closepipe)
|
||||
{
|
||||
struct SIGACTION act;
|
||||
pid_t res;
|
||||
SANE_Pid res;
|
||||
XDBG ((1, "do_cancel\n"));
|
||||
|
||||
s->scanning = SANE_FALSE;
|
||||
|
|
|
@ -282,7 +282,7 @@ struct Artec48U_Scanner
|
|||
Artec48U_Device *dev;
|
||||
Artec48U_Line_Reader *reader;
|
||||
FILE *pipe_handle;
|
||||
int reader_pid;
|
||||
SANE_Pid reader_pid;
|
||||
int pipe;
|
||||
int reader_pipe;
|
||||
SANE_Option_Descriptor opt[NUM_OPTIONS];
|
||||
|
|
|
@ -443,7 +443,7 @@ typedef struct Avision_Scanner
|
|||
/* Avision HW Access Connection (SCSI/USB abstraction) */
|
||||
Avision_Connection av_con;
|
||||
|
||||
pid_t reader_pid; /* process id of reader */
|
||||
SANE_Pid reader_pid; /* process id of reader */
|
||||
int read_fds; /* pipe reading end */
|
||||
int write_fds; /* pipe writing end */
|
||||
|
||||
|
|
|
@ -122,7 +122,7 @@ typedef struct Coolscan
|
|||
|
||||
SANE_Option_Descriptor opt[NUM_OPTIONS];
|
||||
|
||||
pid_t reader_pid;
|
||||
SANE_Pid reader_pid;
|
||||
int reader_fds;
|
||||
int pipe;
|
||||
int scanning;
|
||||
|
|
|
@ -74,7 +74,7 @@ struct hp_handle_s
|
|||
HpDevice dev;
|
||||
SANE_Parameters scan_params;
|
||||
|
||||
pid_t reader_pid;
|
||||
SANE_Pid reader_pid;
|
||||
int child_forked; /* Flag if we used fork() or not */
|
||||
size_t bytes_left;
|
||||
int pipe_read_fd;
|
||||
|
@ -207,7 +207,7 @@ hp_handle_startReader (HpHandle this, HpScsi scsi)
|
|||
return SANE_STATUS_IO_ERROR;
|
||||
}
|
||||
|
||||
DBG(1, "start_reader: reader process %d started\n", this->reader_pid);
|
||||
DBG(1, "start_reader: reader process %ld started\n", (long) this->reader_pid);
|
||||
return SANE_STATUS_GOOD;
|
||||
}
|
||||
|
||||
|
@ -226,7 +226,7 @@ hp_handle_stopScan (HpHandle this)
|
|||
if (this->reader_pid)
|
||||
{
|
||||
int info;
|
||||
DBG(3, "hp_handle_stopScan: killing child (%d)\n", this->reader_pid);
|
||||
DBG(3, "hp_handle_stopScan: killing child (%ld)\n", (long) this->reader_pid);
|
||||
if (this->child_forked)
|
||||
{
|
||||
kill(this->reader_pid, SIGTERM);
|
||||
|
@ -744,8 +744,8 @@ sanei_hp_handle_cancel (HpHandle this)
|
|||
if ( (this->reader_pid)
|
||||
&& (this->dev->compat & HP_COMPAT_OJ_1150C) )
|
||||
{
|
||||
DBG(3,"sanei_hp_handle_cancel: send SIGTERM to child (%d)\n",
|
||||
this->reader_pid);
|
||||
DBG(3,"sanei_hp_handle_cancel: send SIGTERM to child (%ld)\n",
|
||||
(long) this->reader_pid);
|
||||
if (this->child_forked)
|
||||
kill(this->reader_pid, SIGTERM);
|
||||
else
|
||||
|
|
|
@ -164,7 +164,7 @@ struct hp3500_data
|
|||
int sfd;
|
||||
int pipe_r;
|
||||
int pipe_w;
|
||||
int reader_pid;
|
||||
SANE_Pid reader_pid;
|
||||
|
||||
int resolution;
|
||||
int mode;
|
||||
|
|
|
@ -1144,7 +1144,7 @@ typedef struct Microtek2_Scanner {
|
|||
int cancelled;
|
||||
int sfd; /* SCSI filedescriptor */
|
||||
int fd[2]; /* file descriptors for pipe */
|
||||
pid_t pid; /* pid of child process */
|
||||
SANE_Pid pid; /* pid of child process */
|
||||
FILE *fp;
|
||||
|
||||
} Microtek2_Scanner;
|
||||
|
|
|
@ -2952,7 +2952,7 @@ do_stop (Mustek_Scanner * s)
|
|||
struct timeval now;
|
||||
long int scan_time;
|
||||
long int scan_size;
|
||||
pid_t pid;
|
||||
SANE_Pid pid;
|
||||
|
||||
/* print scanning time */
|
||||
gettimeofday (&now, 0);
|
||||
|
|
|
@ -270,7 +270,7 @@ typedef struct Mustek_Scanner
|
|||
SANE_Bool one_pass_color_scan;
|
||||
SANE_Int resolution_code;
|
||||
int fd; /* SCSI filedescriptor */
|
||||
pid_t reader_pid; /* process id of reader */
|
||||
SANE_Pid reader_pid; /* process id of reader */
|
||||
int reader_fds; /* OS/2: pipe write handler for reader */
|
||||
int pipe; /* pipe to reader process */
|
||||
long start_time; /* at this time the scan started */
|
||||
|
|
|
@ -307,7 +307,7 @@ typedef struct Pie_Scanner
|
|||
int scanning; /* true if actually doing a scan */
|
||||
SANE_Parameters params;
|
||||
|
||||
pid_t reader_pid;
|
||||
SANE_Pid reader_pid;
|
||||
int pipe;
|
||||
int reader_fds;
|
||||
|
||||
|
|
|
@ -109,7 +109,7 @@ typedef struct pixma_sane_t
|
|||
unsigned image_bytes_read;
|
||||
unsigned page_count; /* valid for ADF */
|
||||
|
||||
int reader_taskid;
|
||||
SANE_Pid reader_taskid;
|
||||
int wpipe, rpipe;
|
||||
SANE_Bool reader_stop;
|
||||
} pixma_sane_t;
|
||||
|
@ -806,10 +806,10 @@ reader_thread (void *arg)
|
|||
return reader_loop (ss);
|
||||
}
|
||||
|
||||
static int
|
||||
static SANE_Pid
|
||||
terminate_reader_task (pixma_sane_t * ss, int *exit_code)
|
||||
{
|
||||
int result, pid;
|
||||
SANE_Pid result, pid;
|
||||
int status = 0;
|
||||
|
||||
pid = ss->reader_taskid;
|
||||
|
@ -847,7 +847,7 @@ static int
|
|||
start_reader_task (pixma_sane_t * ss)
|
||||
{
|
||||
int fds[2];
|
||||
int pid;
|
||||
SANE_Pid pid;
|
||||
int is_forked;
|
||||
|
||||
if (ss->rpipe != -1 || ss->wpipe != -1)
|
||||
|
@ -862,7 +862,7 @@ start_reader_task (pixma_sane_t * ss)
|
|||
if (ss->reader_taskid != -1)
|
||||
{
|
||||
PDBG (pixma_dbg
|
||||
(1, "BUG:reader_taskid(%d) != -1\n", ss->reader_taskid));
|
||||
(1, "BUG:reader_taskid(%ld) != -1\n", (long) ss->reader_taskid));
|
||||
terminate_reader_task (ss, NULL);
|
||||
}
|
||||
if (pipe (fds) == -1)
|
||||
|
@ -898,7 +898,7 @@ start_reader_task (pixma_sane_t * ss)
|
|||
PDBG (pixma_dbg (1, "ERROR:unable to start reader task\n"));
|
||||
return PIXMA_ENOMEM;
|
||||
}
|
||||
PDBG (pixma_dbg (3, "Reader task id=%d (%s)\n", pid,
|
||||
PDBG (pixma_dbg (3, "Reader task id=%ld (%s)\n", (long) pid,
|
||||
(is_forked) ? "forked" : "threaded"));
|
||||
ss->reader_taskid = pid;
|
||||
return 0;
|
||||
|
@ -957,7 +957,7 @@ read_image (pixma_sane_t * ss, void *buf, unsigned size, int *readlen)
|
|||
ss->image_bytes_read, ss->sp.image_size));
|
||||
close (ss->rpipe);
|
||||
ss->rpipe = -1;
|
||||
if (terminate_reader_task (ss, &status) > 0
|
||||
if (terminate_reader_task (ss, &status) != -1
|
||||
&& status != SANE_STATUS_GOOD)
|
||||
{
|
||||
return status;
|
||||
|
|
|
@ -602,7 +602,7 @@ typedef union
|
|||
typedef struct Plustek_Scanner
|
||||
{
|
||||
struct Plustek_Scanner *next;
|
||||
pid_t reader_pid; /* process id of reader */
|
||||
SANE_Pid reader_pid; /* process id of reader */
|
||||
SANE_Status exit_code; /* status of the reader process */
|
||||
int r_pipe; /* pipe to reader process */
|
||||
int w_pipe; /* pipe from reader process */
|
||||
|
|
|
@ -566,7 +566,7 @@ static SANE_Status
|
|||
do_cancel( Plustek_Scanner *scanner, SANE_Bool closepipe )
|
||||
{
|
||||
struct SIGACTION act;
|
||||
pid_t res;
|
||||
SANE_Pid res;
|
||||
|
||||
DBG( _DBG_PROC,"do_cancel\n" );
|
||||
scanner->scanning = SANE_FALSE;
|
||||
|
|
|
@ -383,7 +383,7 @@ typedef union
|
|||
typedef struct Plustek_Scanner
|
||||
{
|
||||
struct Plustek_Scanner *next;
|
||||
pid_t reader_pid; /* process id of reader */
|
||||
SANE_Pid reader_pid; /* process id of reader */
|
||||
SANE_Status exit_code; /* status of the reader process */
|
||||
int r_pipe; /* pipe to reader process */
|
||||
int w_pipe; /* pipe from reader process */
|
||||
|
|
|
@ -461,7 +461,7 @@ static int reader_process( void *args )
|
|||
static SANE_Status do_cancel( Plustek_Scanner *scanner, SANE_Bool closepipe )
|
||||
{
|
||||
struct SIGACTION act;
|
||||
pid_t res;
|
||||
SANE_Pid res;
|
||||
short int_cnt;
|
||||
|
||||
DBG( _DBG_PROC,"do_cancel\n" );
|
||||
|
|
|
@ -1813,7 +1813,7 @@ void sane_cancel (SANE_Handle h)
|
|||
char *me = "sane_snapscan_cancel";
|
||||
SnapScan_Scanner *pss = (SnapScan_Scanner *) h;
|
||||
struct SIGACTION act;
|
||||
pid_t res;
|
||||
SANE_Pid res;
|
||||
|
||||
DBG (DL_CALL_TRACE, "%s\n", me);
|
||||
switch (pss->state)
|
||||
|
@ -1934,7 +1934,10 @@ SANE_Status sane_get_select_fd (SANE_Handle h, SANE_Int * fd)
|
|||
|
||||
/*
|
||||
* $Log$
|
||||
* Revision 1.71 2008/01/29 17:48:42 kitno-guest
|
||||
* Revision 1.72 2008/05/15 12:50:24 ellert-guest
|
||||
* Fix for bug #306751: sanei-thread with pthreads on 64 bit
|
||||
*
|
||||
* Revision 1.71 2008-01-29 17:48:42 kitno-guest
|
||||
* fix snapscan bug, add LiDE 600F
|
||||
*
|
||||
* Revision 1.70 2007-11-18 10:59:18 ellert-guest
|
||||
|
|
|
@ -353,7 +353,7 @@ struct snapscan_scanner
|
|||
int opens; /* open count */
|
||||
int rpipe[2]; /* reader pipe descriptors */
|
||||
int orig_rpipe_flags; /* initial reader pipe flags */
|
||||
pid_t child; /* child reader process pid */
|
||||
SANE_Pid child; /* child reader process pid */
|
||||
SnapScan_Mode mode; /* mode */
|
||||
SnapScan_Mode preview_mode; /* preview mode */
|
||||
SnapScan_Source source; /* scanning source */
|
||||
|
@ -424,7 +424,10 @@ struct snapscan_scanner
|
|||
|
||||
/*
|
||||
* $Log$
|
||||
* Revision 1.41 2006/02/02 21:28:05 oliver-guest
|
||||
* Revision 1.42 2008/05/15 12:50:24 ellert-guest
|
||||
* Fix for bug #306751: sanei-thread with pthreads on 64 bit
|
||||
*
|
||||
* Revision 1.41 2006-02-02 21:28:05 oliver-guest
|
||||
* Corrected USB ID for Benq 310
|
||||
*
|
||||
* Revision 1.40 2006/01/01 22:57:01 oliver-guest
|
||||
|
|
|
@ -49,7 +49,10 @@ static const char RCSid_h[] = "$Header$";
|
|||
/* ------------------------------------------------------------------------- */
|
||||
/*
|
||||
* $Log$
|
||||
* Revision 1.7 2005/09/19 19:57:48 fzago-guest
|
||||
* Revision 1.8 2008/05/15 12:50:24 ellert-guest
|
||||
* Fix for bug #306751: sanei-thread with pthreads on 64 bit
|
||||
*
|
||||
* Revision 1.7 2005-09-19 19:57:48 fzago-guest
|
||||
* Replaced __unused__ with __sane_unused__ to avoid a namespace conflict.
|
||||
*
|
||||
* Revision 1.6 2004/11/13 19:53:04 fzago-guest
|
||||
|
@ -147,7 +150,7 @@ struct sp15c
|
|||
int scanning; /* "in progress" flag */
|
||||
int autofeeder; /* detected */
|
||||
int use_adf; /* requested */
|
||||
int reader_pid; /* child is running */
|
||||
SANE_Pid reader_pid; /* child is running */
|
||||
int prescan; /* ??? */
|
||||
|
||||
/***** terms for "set window" command *****/
|
||||
|
|
|
@ -113,7 +113,7 @@ typedef struct Tamarack_Scanner
|
|||
int resolution_code;
|
||||
#endif
|
||||
int fd; /* SCSI filedescriptor */
|
||||
pid_t reader_pid; /* process id of reader */
|
||||
SANE_Pid reader_pid; /* process id of reader */
|
||||
int pipe; /* pipe to reader process */
|
||||
int reader_pipe; /* pipe from reader process */
|
||||
|
||||
|
|
|
@ -1351,10 +1351,10 @@ finish_pass (Test_Device * test_device)
|
|||
if (test_device->reader_pid != -1)
|
||||
{
|
||||
int status;
|
||||
int pid;
|
||||
SANE_Pid pid;
|
||||
|
||||
DBG (2, "finish_pass: terminating reader process %d\n",
|
||||
test_device->reader_pid);
|
||||
DBG (2, "finish_pass: terminating reader process %ld\n",
|
||||
(long) test_device->reader_pid);
|
||||
sanei_thread_kill (test_device->reader_pid);
|
||||
pid = sanei_thread_waitpid (test_device->reader_pid, &status);
|
||||
if (pid == -1)
|
||||
|
|
|
@ -126,7 +126,7 @@ typedef struct Test_Device
|
|||
Option_Value val[num_options];
|
||||
SANE_Parameters params;
|
||||
SANE_String name;
|
||||
SANE_Int reader_pid;
|
||||
SANE_Pid reader_pid;
|
||||
SANE_Int reader_fds;
|
||||
SANE_Int pipe;
|
||||
FILE *pipe_handle;
|
||||
|
|
|
@ -385,7 +385,7 @@ static int reader_process( void *args )
|
|||
static SANE_Status do_cancel( U12_Scanner *scanner, SANE_Bool closepipe )
|
||||
{
|
||||
struct SIGACTION act;
|
||||
pid_t res;
|
||||
SANE_Pid res;
|
||||
|
||||
DBG( _DBG_PROC,"do_cancel\n" );
|
||||
|
||||
|
|
|
@ -304,7 +304,7 @@ typedef struct u12d
|
|||
typedef struct u12s
|
||||
{
|
||||
struct u12s *next;
|
||||
pid_t reader_pid; /* process id of reader */
|
||||
SANE_Pid reader_pid; /* process id of reader */
|
||||
SANE_Status exit_code; /* status of the reader process */
|
||||
int r_pipe; /* pipe to reader process */
|
||||
int w_pipe; /* pipe from reader process */
|
||||
|
|
|
@ -4664,7 +4664,8 @@ static size_t max_string_size(SANE_String_Const strings[])
|
|||
|
||||
static SANE_Status do_cancel(Umax_Scanner *scanner)
|
||||
{
|
||||
int pid, status;
|
||||
SANE_Pid pid;
|
||||
int status;
|
||||
|
||||
DBG(DBG_sane_proc,"do_cancel\n");
|
||||
|
||||
|
|
|
@ -487,7 +487,7 @@ typedef struct Umax_Scanner
|
|||
int scanning;
|
||||
SANE_Parameters params;
|
||||
|
||||
pid_t reader_pid;
|
||||
SANE_Pid reader_pid;
|
||||
int pipe_read_fd;
|
||||
int pipe_write_fd;
|
||||
} Umax_Scanner;
|
||||
|
|
|
@ -60,6 +60,12 @@
|
|||
#define sanei_thread_h
|
||||
#include "../include/sane/config.h"
|
||||
|
||||
#ifdef USE_PTHREAD
|
||||
typedef long SANE_Pid;
|
||||
#else
|
||||
typedef int SANE_Pid;
|
||||
#endif
|
||||
|
||||
/** Initialize sanei_thread.
|
||||
*
|
||||
* This function must be called before any other sanei_thread function.
|
||||
|
@ -87,7 +93,7 @@ extern SANE_Bool sanei_thread_is_forked (void);
|
|||
* - task id
|
||||
* - -1 if creating the new task failed
|
||||
*/
|
||||
extern int sanei_thread_begin (int (*func) (void *args), void *args);
|
||||
extern SANE_Pid sanei_thread_begin (int (*func) (void *args), void *args);
|
||||
|
||||
/** Terminate spawned task.
|
||||
*
|
||||
|
@ -102,7 +108,7 @@ extern int sanei_thread_begin (int (*func) (void *args), void *args);
|
|||
* - 0 on success
|
||||
* - any other value if an error occured while terminating the task
|
||||
*/
|
||||
extern int sanei_thread_kill (int pid);
|
||||
extern int sanei_thread_kill (SANE_Pid pid);
|
||||
|
||||
/** Send a signal to a task.
|
||||
*
|
||||
|
@ -117,7 +123,7 @@ extern int sanei_thread_kill (int pid);
|
|||
* - 0 - on success
|
||||
* - any other value - if an error occured while sending the signal
|
||||
*/
|
||||
extern int sanei_thread_sendsig (int pid, int sig);
|
||||
extern int sanei_thread_sendsig (SANE_Pid pid, int sig);
|
||||
|
||||
/** Wait for task termination.
|
||||
*
|
||||
|
@ -131,7 +137,7 @@ extern int sanei_thread_sendsig (int pid, int sig);
|
|||
* @return
|
||||
* - the pid of the task we have been waiting for
|
||||
*/
|
||||
extern int sanei_thread_waitpid (int pid, int *status);
|
||||
extern SANE_Pid sanei_thread_waitpid (SANE_Pid pid, int *status);
|
||||
|
||||
/** Check the current status of the spawned task
|
||||
*
|
||||
|
@ -142,6 +148,6 @@ extern int sanei_thread_waitpid (int pid, int *status);
|
|||
* - SANE_STATUS_GOOD - if the task finished without errors
|
||||
* - any other value - if the task finished unexpectantly or hasn't finished yet
|
||||
*/
|
||||
extern SANE_Status sanei_thread_get_status (int pid);
|
||||
extern SANE_Status sanei_thread_get_status (SANE_Pid pid);
|
||||
|
||||
#endif /* sanei_thread_h */
|
||||
|
|
|
@ -117,9 +117,9 @@ sanei_thread_is_forked( void )
|
|||
}
|
||||
|
||||
int
|
||||
sanei_thread_kill( int pid )
|
||||
sanei_thread_kill( SANE_Pid pid )
|
||||
{
|
||||
DBG(2, "sanei_thread_kill() will kill %d\n", (int)pid);
|
||||
DBG(2, "sanei_thread_kill() will kill %ld\n", (long) pid);
|
||||
#ifdef USE_PTHREAD
|
||||
#if defined (__APPLE__) && defined (__MACH__)
|
||||
return pthread_kill((pthread_t)pid, SIGUSR2);
|
||||
|
@ -154,10 +154,10 @@ local_thread( void *arg )
|
|||
* args pointer to scanner data structure
|
||||
*
|
||||
*/
|
||||
int
|
||||
SANE_Pid
|
||||
sanei_thread_begin( int (*func)(void *args), void* args )
|
||||
{
|
||||
int pid;
|
||||
SANE_Pid pid;
|
||||
|
||||
td.func = func;
|
||||
td.func_data = args;
|
||||
|
@ -172,8 +172,8 @@ sanei_thread_begin( int (*func)(void *args), void* args )
|
|||
return pid;
|
||||
}
|
||||
|
||||
int
|
||||
sanei_thread_waitpid( int pid, int *status )
|
||||
SANE_Pid
|
||||
sanei_thread_waitpid( SANE_Pid pid, int *status )
|
||||
{
|
||||
if (status)
|
||||
*status = 0;
|
||||
|
@ -181,7 +181,7 @@ sanei_thread_waitpid( int pid, int *status )
|
|||
}
|
||||
|
||||
int
|
||||
sanei_thread_sendsig( int pid, int sig )
|
||||
sanei_thread_sendsig( SANE_Pid pid, int sig )
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
@ -207,10 +207,10 @@ local_thread( void *arg )
|
|||
* args pointer to scanner data structure
|
||||
*
|
||||
*/
|
||||
int
|
||||
SANE_Pid
|
||||
sanei_thread_begin( int (*func)(void *args), void* args )
|
||||
{
|
||||
int pid;
|
||||
SANE_Pid pid;
|
||||
|
||||
td.func = func;
|
||||
td.func_data = args;
|
||||
|
@ -229,8 +229,8 @@ sanei_thread_begin( int (*func)(void *args), void* args )
|
|||
return pid;
|
||||
}
|
||||
|
||||
int
|
||||
sanei_thread_waitpid( int pid, int *status )
|
||||
SANE_Pid
|
||||
sanei_thread_waitpid( SANE_Pid pid, int *status )
|
||||
{
|
||||
int32 st;
|
||||
if ( wait_for_thread(pid, &st) < B_OK )
|
||||
|
@ -241,7 +241,7 @@ sanei_thread_waitpid( int pid, int *status )
|
|||
}
|
||||
|
||||
int
|
||||
sanei_thread_sendsig( int pid, int sig )
|
||||
sanei_thread_sendsig( SANE_Pid pid, int sig )
|
||||
{
|
||||
if (sig == SIGKILL)
|
||||
sig = SIGKILLTHR;
|
||||
|
@ -325,7 +325,7 @@ restore_sigpipe( void )
|
|||
#else /* the process stuff */
|
||||
|
||||
static int
|
||||
eval_wp_result( int pid, int wpres, int pf )
|
||||
eval_wp_result( SANE_Pid pid, int wpres, int pf )
|
||||
{
|
||||
int retval = SANE_STATUS_IO_ERROR;
|
||||
|
||||
|
@ -348,12 +348,12 @@ eval_wp_result( int pid, int wpres, int pf )
|
|||
}
|
||||
#endif
|
||||
|
||||
int
|
||||
SANE_Pid
|
||||
sanei_thread_begin( int (func)(void *args), void* args )
|
||||
{
|
||||
int pid;
|
||||
#ifdef USE_PTHREAD
|
||||
struct sigaction act;
|
||||
int result;
|
||||
pthread_t thread;
|
||||
|
||||
/* if signal handler for SIGPIPE is SIG_DFL, replace by SIG_IGN */
|
||||
|
@ -372,17 +372,18 @@ sanei_thread_begin( int (func)(void *args), void* args )
|
|||
td.func = func;
|
||||
td.func_data = args;
|
||||
|
||||
pid = pthread_create( &thread, NULL, local_thread, &td );
|
||||
result = pthread_create( &thread, NULL, local_thread, &td );
|
||||
usleep( 1 );
|
||||
|
||||
if ( pid != 0 ) {
|
||||
DBG( 1, "pthread_create() failed with %d\n", pid );
|
||||
if ( result != 0 ) {
|
||||
DBG( 1, "pthread_create() failed with %d\n", result );
|
||||
return -1;
|
||||
}
|
||||
|
||||
DBG( 2, "pthread_create() created thread %d\n", (int)thread );
|
||||
return (int)thread;
|
||||
DBG( 2, "pthread_create() created thread %ld\n", (SANE_Pid)thread );
|
||||
return (SANE_Pid)thread;
|
||||
#else
|
||||
SANE_Pid pid;
|
||||
pid = fork();
|
||||
if( pid < 0 ) {
|
||||
DBG( 1, "fork() failed\n" );
|
||||
|
@ -392,7 +393,7 @@ sanei_thread_begin( int (func)(void *args), void* args )
|
|||
if( pid == 0 ) {
|
||||
|
||||
/* run in child context... */
|
||||
int status = func( args );
|
||||
int status = func( args );
|
||||
|
||||
/* don't use exit() since that would run the atexit() handlers */
|
||||
_exit( status );
|
||||
|
@ -404,32 +405,33 @@ sanei_thread_begin( int (func)(void *args), void* args )
|
|||
}
|
||||
|
||||
int
|
||||
sanei_thread_sendsig( int pid, int sig )
|
||||
sanei_thread_sendsig( SANE_Pid pid, int sig )
|
||||
{
|
||||
#ifdef USE_PTHREAD
|
||||
DBG(2, "sanei_thread_sendsig() %d to thread(id=%d)\n", sig, pid);
|
||||
return pthread_kill((pthread_t)pid, sig );
|
||||
DBG(2, "sanei_thread_sendsig() %d to thread (id=%ld)\n", sig, pid);
|
||||
return pthread_kill( (pthread_t)pid, sig );
|
||||
#else
|
||||
DBG(2, "sanei_thread_sendsig() %d to process (id=%d)\n", sig, pid);
|
||||
return kill( pid, sig );
|
||||
#endif
|
||||
}
|
||||
|
||||
int
|
||||
sanei_thread_waitpid( int pid, int *status )
|
||||
SANE_Pid
|
||||
sanei_thread_waitpid( SANE_Pid pid, int *status )
|
||||
{
|
||||
#ifdef USE_PTHREAD
|
||||
int *ls;
|
||||
#else
|
||||
int ls;
|
||||
#endif
|
||||
int result, stat;
|
||||
SANE_Pid result;
|
||||
int stat;
|
||||
|
||||
stat = 0;
|
||||
|
||||
DBG(2, "sanei_thread_waitpid() - %d\n", pid);
|
||||
DBG(2, "sanei_thread_waitpid() - %ld\n", (long) pid);
|
||||
#ifdef USE_PTHREAD
|
||||
result = pthread_join((pthread_t)pid, (void*)&ls );
|
||||
result = pthread_join( (pthread_t)pid, (void*)&ls );
|
||||
|
||||
if( 0 == result ) {
|
||||
if( PTHREAD_CANCELED == ls ) {
|
||||
|
@ -444,7 +446,7 @@ sanei_thread_waitpid( int pid, int *status )
|
|||
/* call detach in any case to make sure that the thread resources
|
||||
* will be freed, when the thread has terminated
|
||||
*/
|
||||
DBG(2, "* detaching thread(%d)\n", pid );
|
||||
DBG(2, "* detaching thread(%ld)\n", pid );
|
||||
pthread_detach((pthread_t)pid);
|
||||
if (status)
|
||||
*status = stat;
|
||||
|
@ -468,7 +470,7 @@ sanei_thread_waitpid( int pid, int *status )
|
|||
#endif /* HAVE_OS2_H */
|
||||
|
||||
SANE_Status
|
||||
sanei_thread_get_status( int pid )
|
||||
sanei_thread_get_status( SANE_Pid pid )
|
||||
{
|
||||
#if defined USE_PTHREAD || defined HAVE_OS2_H || defined __BEOS__
|
||||
_VAR_NOT_USED( pid );
|
||||
|
|
Ładowanie…
Reference in New Issue