*** empty log message ***

merge-requests/1/head
Michael Herder 2004-05-15 13:09:45 +00:00
rodzic aa7f92c063
commit 20fded72e9
3 zmienionych plików z 45 dodań i 73 usunięć

Wyświetl plik

@ -1,10 +1,16 @@
2004-05-15 Stéphane Voltz <svoltz@wanadoo.fr> 2004-05-15 Michael Herder <crapmail@nurfuerspam.de>
* backend/artec_eplus48u.c backend/artec_eplus48u.h:
applied patch from Mattias Ellert (thanks), which adds support
for sanei_thread
2004-05-15 St<53>hane Voltz <svoltz@wanadoo.fr>
* backend/umax_pp_low.c backend/umax_pp.c tools/umax_pp.c: fixed * backend/umax_pp_low.c backend/umax_pp.c tools/umax_pp.c: fixed
origin shift bug for 610P. Added on guard against configuration origin shift bug for 610P. Added on guard against configuration
that can put several 'port' option in conf file. that can put several 'port' option in conf file.
2004-05-13 Stéphane Voltz <svoltz@wanadoo.fr> 2004-05-13 St<EFBFBD>hane Voltz <svoltz@wanadoo.fr>
* backend/umax_pp_low.c backend/umax_pp.c tools/umax_pp.c: fixed * backend/umax_pp_low.c backend/umax_pp.c tools/umax_pp.c: fixed
data lines reordering for 610P data lines reordering for 610P
@ -18,7 +24,7 @@
* Makefile.in: Remove autoconf temp files and some japi stuff in * Makefile.in: Remove autoconf temp files and some japi stuff in
distclean target. distclean target.
2004-05-10 Stéphane Voltz <svoltz@wanadoo.fr> 2004-05-10 St<EFBFBD>hane Voltz <svoltz@wanadoo.fr>
* backend/umax_pp_low.c : fixed 300x600 dpi scans, direct * backend/umax_pp_low.c : fixed 300x600 dpi scans, direct
hardware access and timing issues for 610P hardware access and timing issues for 610P
@ -38,7 +44,7 @@
* tools/hotplug/libsane.usbmap: removed empty lines, latest * tools/hotplug/libsane.usbmap: removed empty lines, latest
hotplug cannot cope with them hotplug cannot cope with them
2004-03-15 Stéphane Voltz <svoltz@wanadoo.fr> 2004-03-15 St<EFBFBD>hane Voltz <svoltz@wanadoo.fr>
* backend/umax_pp_low.c backend/umax_pp_low.h backend/umax_pp_mid.c * backend/umax_pp_low.c backend/umax_pp_low.h backend/umax_pp_mid.c
backend/umax_pp_mid.h backend/umax_pp.c backend/umax_pp.h backend/umax_pp_mid.h backend/umax_pp.c backend/umax_pp.h

Wyświetl plik

@ -83,7 +83,6 @@ Updates (C) 2001 by Henning Meier-Geinitz.
#include <math.h> #include <math.h>
#include <sys/time.h> #include <sys/time.h>
#include <sys/wait.h>
#include <sys/stat.h> #include <sys/stat.h>
#include <sys/types.h> #include <sys/types.h>
#include <sys/ioctl.h> #include <sys/ioctl.h>
@ -3388,13 +3387,30 @@ sig_chldhandler (int signo)
XDBG ((1, "Child is down (signal=%d)\n", signo)); XDBG ((1, "Child is down (signal=%d)\n", signo));
} }
static SANE_Status static int
reader_process (Artec48U_Scanner * s, SANE_Int fd) reader_process (void * data)
{ {
Artec48U_Scanner * s = (Artec48U_Scanner *) data;
int fd = s->reader_pipe;
SANE_Status status; SANE_Status status;
struct SIGACTION act; struct SIGACTION act;
sigset_t ignore_set;
ssize_t bytes_written = 0; ssize_t bytes_written = 0;
XDBG ((1, "reader process...\n"));
if (sanei_thread_is_forked()) close (s->pipe);
sigfillset (&ignore_set);
sigdelset (&ignore_set, SIGTERM);
sigdelset (&ignore_set, SIGUSR1);
sigprocmask (SIG_SETMASK, &ignore_set, 0);
memset (&act, 0, sizeof (act));
sigaction (SIGTERM, &act, 0);
sigaction (SIGUSR1, &act, 0);
cancelRead = SANE_FALSE; cancelRead = SANE_FALSE;
if (sigemptyset (&(act.sa_mask)) < 0) if (sigemptyset (&(act.sa_mask)) < 0)
XDBG ((2, "(child) reader_process: sigemptyset() failed\n")); XDBG ((2, "(child) reader_process: sigemptyset() failed\n"));
@ -3451,6 +3467,7 @@ reader_process (Artec48U_Scanner * s, SANE_Int fd)
XDBG ((2, "(child) reader_process: lines to read %i\n", s->lines_to_read)); XDBG ((2, "(child) reader_process: lines to read %i\n", s->lines_to_read));
} }
s->eof = SANE_TRUE; s->eof = SANE_TRUE;
close (fd);
return SANE_STATUS_GOOD; return SANE_STATUS_GOOD;
} }
@ -3478,14 +3495,14 @@ do_cancel (Artec48U_Scanner * s, SANE_Bool closepipe)
/* kill our child process and wait until done */ /* kill our child process and wait until done */
alarm (10); alarm (10);
if (kill (s->reader_pid, SIGKILL) < 0) if (sanei_thread_kill (s->reader_pid) < 0)
XDBG ((1, "kill() failed !\n")); XDBG ((1, "sanei_thread_kill() failed !\n"));
res = waitpid (s->reader_pid, 0, 0); res = sanei_thread_waitpid (s->reader_pid, 0);
alarm (0); alarm (0);
if (res != s->reader_pid) if (res != s->reader_pid)
{ {
XDBG ((1, "waitpid() failed !\n")); XDBG ((1, "sanei_thread_waitpid() failed !\n"));
} }
s->reader_pid = 0; s->reader_pid = 0;
XDBG ((1, "reader_process killed\n")); XDBG ((1, "reader_process killed\n"));
@ -3549,36 +3566,6 @@ sane_get_devices (const SANE_Device *** device_list, SANE_Bool local_only)
return SANE_STATUS_GOOD; return SANE_STATUS_GOOD;
} }
static SANE_Bool
getReaderProcessExitCode (Artec48U_Scanner * s)
{
int res;
int status;
s->exit_code = SANE_STATUS_IO_ERROR;
if (s->reader_pid > 0)
{
res = waitpid (s->reader_pid, &status, WNOHANG);
if (res == s->reader_pid)
{
XDBG ((2, "res=%i, status=%i\n", res, status));
if (WIFEXITED (status))
{
s->exit_code = WEXITSTATUS (status);
XDBG ((2, "Child WEXITSTATUS = %d\n", s->exit_code));
}
else
{
s->exit_code = SANE_STATUS_GOOD;
XDBG ((2, "Child termination okay\n"));
}
return SANE_TRUE;
}
}
return SANE_FALSE;
}
static SANE_Status static SANE_Status
load_calibration_data (Artec48U_Scanner * s) load_calibration_data (Artec48U_Scanner * s)
{ {
@ -4291,43 +4278,19 @@ sane_start (SANE_Handle handle)
XDBG ((2, "sane_start: could not start scan\n")); XDBG ((2, "sane_start: could not start scan\n"));
return status; return status;
} }
s->reader_pid = fork (); s->pipe = fds[0];
s->reader_pipe = fds[1];
s->reader_pid = sanei_thread_begin (reader_process, s);
cancelRead = SANE_FALSE; cancelRead = SANE_FALSE;
if (s->reader_pid == 0) /* child */ if (s->reader_pid < 0)
{
sigset_t ignore_set;
struct SIGACTION act;
XDBG ((1, "reader process...\n"));
close (fds[0]);
sigfillset (&ignore_set);
sigdelset (&ignore_set, SIGTERM);
sigdelset (&ignore_set, SIGUSR1);
sigprocmask (SIG_SETMASK, &ignore_set, 0);
memset (&act, 0, sizeof (act));
sigaction (SIGTERM, &act, 0);
sigaction (SIGUSR1, &act, 0);
status = reader_process (s, fds[1]);
XDBG ((1, "reader process done, status = %i\n", status));
/* don't use exit() since that would run the atexit() handlers */
_exit (status);
}
else if (s->reader_pid < 0)
{ {
s->scanning = SANE_FALSE; s->scanning = SANE_FALSE;
XDBG ((2, "sane_start: fork failed (%s)\n", strerror (errno))); XDBG ((2, "sane_start: sanei_thread_begin failed (%s)\n", strerror (errno)));
return SANE_STATUS_NO_MEM; return SANE_STATUS_NO_MEM;
} }
signal (SIGCHLD, sig_chldhandler); signal (SIGCHLD, sig_chldhandler);
close (fds[1]); if (sanei_thread_is_forked()) close (s->reader_pipe);
s->pipe = fds[0];
XDBG ((1, "sane_start done\n")); XDBG ((1, "sane_start done\n"));
@ -4358,7 +4321,7 @@ sane_read (SANE_Handle handle, SANE_Byte * data,
/* if we already had read the picture, so it's okay and stop */ /* if we already had read the picture, so it's okay and stop */
if (s->eof == SANE_TRUE) if (s->eof == SANE_TRUE)
{ {
waitpid (s->reader_pid, 0, 0); sanei_thread_waitpid (s->reader_pid, 0);
s->reader_pid = -1; s->reader_pid = -1;
artec48u_scanner_stop_scan (s); artec48u_scanner_stop_scan (s);
artec48u_carriage_home (s->dev); artec48u_carriage_home (s->dev);
@ -4383,7 +4346,7 @@ sane_read (SANE_Handle handle, SANE_Byte * data,
{ {
if (0 == s->byte_cnt) if (0 == s->byte_cnt)
{ {
getReaderProcessExitCode (s); s->exit_code = sanei_thread_get_status (s->reader_pid);
if (SANE_STATUS_GOOD != s->exit_code) if (SANE_STATUS_GOOD != s->exit_code)
{ {
@ -4476,6 +4439,7 @@ sane_init (SANE_Int * version_code, SANE_Auth_Callback authorize)
strcpy (model_string, "E+ 48U"); strcpy (model_string, "E+ 48U");
sanei_usb_init (); sanei_usb_init ();
sanei_thread_init ();
/* do some presettings... */ /* do some presettings... */
auth = authorize; auth = authorize;

Wyświetl plik

@ -11,6 +11,7 @@
#include <errno.h> #include <errno.h>
#include "../include/sane/sanei_usb.h" #include "../include/sane/sanei_usb.h"
#include "../include/sane/sanei_thread.h"
#define _MAX_ID_LEN 20 #define _MAX_ID_LEN 20
@ -281,6 +282,7 @@ struct Artec48U_Scanner
FILE *pipe_handle; FILE *pipe_handle;
int reader_pid; int reader_pid;
int pipe; int pipe;
int reader_pipe;
SANE_Option_Descriptor opt[NUM_OPTIONS]; SANE_Option_Descriptor opt[NUM_OPTIONS];
Option_Value val[NUM_OPTIONS]; Option_Value val[NUM_OPTIONS];
SANE_Status exit_code; SANE_Status exit_code;