diff --git a/ChangeLog b/ChangeLog index d1c49cf0c..1d1bd6cb3 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2003-02-17 Henning Meier-Geinitz + + * backend/mustek.c doc/descriptions/mustek.desc + doc/mustek/mustek.CHANGES: Make sure that the result of the + reader_process is interpreted correctly. Block signals when waiting + for a SCSI request to finish. Otherwise we may get a segfault if the + reader_process is terminated while waiting. + 2003-02-16 Henning Meier-Geinitz * doc/doxygen-sanei.conf: Updated version. diff --git a/backend/mustek.c b/backend/mustek.c index ec49fc202..c8efd18d2 100644 --- a/backend/mustek.c +++ b/backend/mustek.c @@ -46,7 +46,7 @@ /**************************************************************************/ /* Mustek backend version */ -#define BUILD 130 +#define BUILD 131 /**************************************************************************/ #include "../include/sane/config.h" @@ -2843,17 +2843,31 @@ do_stop (Mustek_Scanner * s) /* ensure child knows it's time to stop: */ DBG (5, "do_stop: terminating reader process\n"); kill (s->reader_pid, SIGTERM); + pid = waitpid (s->reader_pid, &exit_status, 0); + if (pid < 0) + { + DBG (1, "do_stop: waitpid failed, already terminated? (%s)\n", + strerror (errno)); + } + else if (WIFEXITED (exit_status)) + { + DBG (2, "do_stop: reader process terminated with status %s\n", + sane_strstatus (WEXITSTATUS (exit_status))); + if (status != SANE_STATUS_CANCELLED + && WEXITSTATUS (exit_status) != SANE_STATUS_GOOD) + status = WEXITSTATUS (exit_status); + } + else if (WIFSIGNALED (status)) + { + DBG (2, "do_stop: reader process was terminated by signal %d\n", + WTERMSIG (exit_status)); + if (WTERMSIG (exit_status) != 15) + status = SANE_STATUS_IO_ERROR; + } + else + DBG (1, "do_stop: reader process terminated by unknown reason\n"); - if (status != SANE_STATUS_CANCELLED && pid > 0 - && WIFEXITED (exit_status)) - status = WEXITSTATUS (exit_status); - - DBG (5, "do_stop: reader process terminated: %s\n", - sane_strstatus (status)); - if (pid <= 0) - DBG (5, "do_stop: reader process already terminated (%s)\n", - strerror (errno)); s->reader_pid = 0; } @@ -4839,7 +4853,9 @@ reader_process (Mustek_Scanner * s, SANE_Int fd) { DBG (4, "reader_process: buffer %d: waiting for request to be " "ready\n", buffernumber + 1); + sigprocmask (SIG_BLOCK, &sigterm_set, 0); status = dev_req_wait (bstat[buffernumber].id); + sigprocmask (SIG_UNBLOCK, &sigterm_set, 0); if (status == SANE_STATUS_GOOD) { DBG (4, "reader_process: buffer %d is ready, wanted %d, " diff --git a/doc/descriptions/mustek.desc b/doc/descriptions/mustek.desc index 5bfc6dd53..495ecbacc 100644 --- a/doc/descriptions/mustek.desc +++ b/doc/descriptions/mustek.desc @@ -9,7 +9,7 @@ ; :backend "mustek" ; name of backend -:version "1.0-130" ; version of backend +:version "1.0-131" ; version of backend :status :stable ; :alpha, :beta, :stable, :new :manpage "sane-mustek" ; name of manpage (if it exists) :url "http://www.meier-geinitz.de/sane/mustek-backend/" diff --git a/doc/mustek/mustek.CHANGES b/doc/mustek/mustek.CHANGES index a709c4c4a..f879ce303 100644 --- a/doc/mustek/mustek.CHANGES +++ b/doc/mustek/mustek.CHANGES @@ -1,5 +1,13 @@ CHANGES for the SANE Mustek backend +2003-02-17 + * Released Mustek backend 1.0-131 + +2003-02-17 + * Make sure that the result of the reader_process is interpreted correctly. + * Block signals when waiting for a SCSI request to finish. Otherwise we may + get a segfault if the reader_process is terminated while waiting. + 2002-11-29 * Released Mustek backend 1.0-130