Protected blanker and formatter thread from signals

This commit is contained in:
Thomas Schmitt 2010-03-05 18:59:21 +00:00
parent 72f9ff8b8c
commit 873e3f5d78
2 changed files with 60 additions and 20 deletions

View File

@ -1 +1 @@
#define Cdrskin_timestamP "2010.03.05.111712" #define Cdrskin_timestamP "2010.03.05.190110"

View File

@ -318,8 +318,27 @@ drive_is_active:;
static void *erase_worker_func(struct w_list *w) static void *erase_worker_func(struct w_list *w)
{ {
#define Libburn_protect_erase_threaD 1
#ifdef Libburn_protect_erase_threaD
sigset_t sigset, oldset;
/* Protect blank thread from being interrupted by external signals */
sigfillset(&sigset);
sigdelset(&sigset, SIGSEGV);
sigdelset(&sigset, SIGILL);
pthread_sigmask(SIG_SETMASK, &sigset, &oldset);
#endif /* Libburn_protect_erase_threaD */
burn_disc_erase_sync(w->u.erase.drive, w->u.erase.fast); burn_disc_erase_sync(w->u.erase.drive, w->u.erase.fast);
remove_worker(pthread_self()); remove_worker(pthread_self());
#ifdef Libburn_protect_erase_threaD
/* (just in case it would not end with all signals blocked) */
pthread_sigmask(SIG_SETMASK, &oldset, NULL);
#endif /* Libburn_protect_erase_threaD */
return NULL; return NULL;
} }
@ -390,9 +409,28 @@ void burn_disc_erase(struct burn_drive *drive, int fast)
/* ts A61230 */ /* ts A61230 */
static void *format_worker_func(struct w_list *w) static void *format_worker_func(struct w_list *w)
{ {
#define Libburn_protect_format_threaD 1
#ifdef Libburn_protect_format_threaD
sigset_t sigset, oldset;
/* Protect format thread from being interrupted by external signals */
sigfillset(&sigset);
sigdelset(&sigset, SIGSEGV);
sigdelset(&sigset, SIGILL);
pthread_sigmask(SIG_SETMASK, &sigset, &oldset);
#endif /* Libburn_protect_format_threaD */
burn_disc_format_sync(w->u.format.drive, w->u.format.size, burn_disc_format_sync(w->u.format.drive, w->u.format.size,
w->u.format.flag); w->u.format.flag);
remove_worker(pthread_self()); remove_worker(pthread_self());
#ifdef Libburn_protect_format_threaD
/* (just in case it would not end with all signals blocked) */
pthread_sigmask(SIG_SETMASK, &oldset, NULL);
#endif /* Libburn_protect_format_threaD */
return NULL; return NULL;
} }
@ -565,13 +603,14 @@ static void *write_disc_worker_func(struct w_list *w)
LIBDAX_MSGS_SEV_DEBUG, LIBDAX_MSGS_PRIO_HIGH, LIBDAX_MSGS_SEV_DEBUG, LIBDAX_MSGS_PRIO_HIGH,
msg, 0, 0); msg, 0, 0);
remove_worker(pthread_self());
d->busy = BURN_DRIVE_IDLE;
#ifdef Libburn_protect_write_threaD #ifdef Libburn_protect_write_threaD
/* (just in case it would not end with all signals blocked) */ /* (just in case it would not end with all signals blocked) */
pthread_sigmask(SIG_SETMASK, &oldset, NULL); pthread_sigmask(SIG_SETMASK, &oldset, NULL);
#endif /* Libburn_protect_write_threaD */ #endif /* Libburn_protect_write_threaD */
remove_worker(pthread_self());
d->busy = BURN_DRIVE_IDLE;
return NULL; return NULL;
} }
@ -664,12 +703,30 @@ static void *fifo_worker_func(struct w_list *w)
{ {
int old; int old;
#define Libburn_protect_fifo_threaD 1
#ifdef Libburn_protect_fifo_threaD
sigset_t sigset, oldset;
/* Protect fifo thread from being interrupted by external signals */
sigfillset(&sigset);
sigdelset(&sigset, SIGSEGV);
sigdelset(&sigset, SIGILL);
pthread_sigmask(SIG_SETMASK, &sigset, &oldset);
#endif /* Libburn_protect_fifo_threaD */
pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, &old); pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, &old);
pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, &old); pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, &old);
/* Note: Only burn_fifo_abort() shall cancel the fifo thread */ /* Note: Only burn_fifo_abort() shall cancel the fifo thread */
burn_fifo_source_shoveller(w->u.fifo.source, w->u.fifo.flag); burn_fifo_source_shoveller(w->u.fifo.source, w->u.fifo.flag);
remove_worker(pthread_self()); remove_worker(pthread_self());
#ifdef Libburn_protect_fifo_threaD
/* (just in case it would not end with all signals blocked) */
pthread_sigmask(SIG_SETMASK, &oldset, NULL);
#endif /* Libburn_protect_fifo_threaD */
return NULL; return NULL;
} }
@ -679,18 +736,6 @@ int burn_fifo_start(struct burn_source *source, int flag)
struct fifo_opts o; struct fifo_opts o;
struct burn_source_fifo *fs = source->data; struct burn_source_fifo *fs = source->data;
#define Libburn_protect_fifo_threaD 1
#ifdef Libburn_protect_fifo_threaD
sigset_t sigset, oldset;
/* Protect write thread from being interrupted by external signals */
sigfillset(&sigset);
sigdelset(&sigset, SIGSEGV);
sigdelset(&sigset, SIGILL);
pthread_sigmask(SIG_SETMASK, &sigset, &oldset);
#endif /* Libburn_protect_fifo_threaD */
fs->is_started = -1; fs->is_started = -1;
/* create and set up ring buffer */; /* create and set up ring buffer */;
@ -707,11 +752,6 @@ int burn_fifo_start(struct burn_source *source, int flag)
(WorkerFunc) fifo_worker_func, &o); (WorkerFunc) fifo_worker_func, &o);
fs->is_started = 1; fs->is_started = 1;
#ifdef Libburn_protect_fifo_threaD
/* (just in case it would not end with all signals blocked) */
pthread_sigmask(SIG_SETMASK, &oldset, NULL);
#endif /* Libburn_protect_fifo_threaD */
return 1; return 1;
} }