"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "libburn/async.c" between
xorriso-1.4.6.tar.gz and xorriso-1.4.8.tar.gz

About: GNU xorriso creates, loads, manipulates and writes ISO 9660 filesystem images with Rock Ridge extensions. It is suitable for incremental data backup and for production of bootable ISO 9660 images. GNU xorriso is a statical compilation of the libraries libburn, libisofs, libisoburn, and libjte.

async.c  (xorriso-1.4.6):async.c  (xorriso-1.4.8)
/* -*- indent-tabs-mode: t; tab-width: 8; c-basic-offset: 8; -*- */ /* -*- indent-tabs-mode: t; tab-width: 8; c-basic-offset: 8; -*- */
/* Copyright (c) 2004 - 2006 Derek Foreman, Ben Jansens /* Copyright (c) 2004 - 2006 Derek Foreman, Ben Jansens
Copyright (c) 2006 - 2014 Thomas Schmitt <scdbackup@gmx.net> Copyright (c) 2006 - 2017 Thomas Schmitt <scdbackup@gmx.net>
Provided under GPL version 2 or later. Provided under GPL version 2 or later.
*/ */
/* ts A71019 */ /* ts A71019 */
/* Standard measure should be: Threads are created detached. /* Standard measure should be: Threads are created detached.
According to the man pages they should then care for disposing themselves. According to the man pages they should then care for disposing themselves.
>>> ??? It is yet unclear why the threads vanish from the process list >>> ??? It is yet unclear why the threads vanish from the process list
even if joinable and even if never joined. even if joinable and even if never joined.
skipping to change at line 125 skipping to change at line 125
struct burn_drive *drive; struct burn_drive *drive;
pthread_t thread; pthread_t thread;
struct w_list *next; struct w_list *next;
union w_list_data u; union w_list_data u;
}; };
static struct w_list *workers = NULL; static struct w_list *workers = NULL;
int burn_async_manage_lock(int mode)
{
int ret;
static pthread_mutex_t access_lock;
static int mutex_initialized = 0;
static int mutex_locked = 0;
if (mode == BURN_ASYNC_LOCK_INIT) {
if (mutex_initialized)
return 2;
ret = pthread_mutex_init(&access_lock, NULL);
if (ret != 0)
return 0;
mutex_initialized = 1;
return 1;
}
if (!mutex_initialized)
return 0;
if (mode == BURN_ASYNC_LOCK_OBTAIN) {
ret = pthread_mutex_lock(&access_lock);
if (ret != 0)
return 0;
mutex_locked = 1;
} else if (mode == BURN_ASYNC_LOCK_RELEASE) {
if (!mutex_locked)
return 2;
ret = pthread_mutex_unlock(&access_lock);
if (ret != 0)
return 0;
mutex_locked = 0;
}
return 1;
}
static struct w_list *find_worker(struct burn_drive *d) static struct w_list *find_worker(struct burn_drive *d)
{ {
struct w_list *a; struct w_list *a;
for (a = workers; a; a = a->next) for (a = workers; a; a = a->next)
if (a->drive == d) if (a->drive == d)
return a; return a;
return NULL; return NULL;
} }
skipping to change at line 151 skipping to change at line 186
#ifdef Libburn_create_detached_threadS #ifdef Libburn_create_detached_threadS
pthread_attr_t attr; pthread_attr_t attr;
#endif #endif
a = calloc(1, sizeof(struct w_list)); a = calloc(1, sizeof(struct w_list));
a->w_type = w_type; a->w_type = w_type;
a->drive = d; a->drive = d;
a->u = *data; a->u = *data;
/*
memcpy(&(a->u), data, sizeof(union w_list_data)); burn_async_manage_lock(BURN_ASYNC_LOCK_INIT);
*/
/* insert at front of the list */ /* insert at front of the list */
a->next = workers; a->next = workers;
tmp = workers; tmp = workers;
workers = a; workers = a;
if (d != NULL) if (d != NULL)
d->busy = BURN_DRIVE_SPAWNING; d->busy = BURN_DRIVE_SPAWNING;
#ifdef Libburn_create_detached_threadS #ifdef Libburn_create_detached_threadS
/* ts A71019 : /* ts A71019 :
Trying to start the threads detached to get rid of the zombies Trying to start the threads detached to get rid of the zombies
which do neither react on pthread_join() nor on pthread_detach(). which do neither react on pthread_join() nor on pthread_detach().
*/ */
pthread_attr_init(&attr); pthread_attr_init(&attr);
pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED); pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
attr_pt= &attr; attr_pt= &attr;
/*
libdax_msgs_submit(libdax_messenger, -1, 0x00020158, #endif /* Libburn_create_detached_threadS */
LIBDAX_MSGS_SEV_DEBUG, LIBDAX_MSGS_PRIO_LOW,
"add_worker(): Creating detached thread.", 0, 0); /* Worker specific locks are to be released early by the worker */
*/ if (f == (WorkerFunc) burn_fifo_source_shoveller)
#endif burn_async_manage_lock(BURN_ASYNC_LOCK_OBTAIN);
if (pthread_create(&a->thread, attr_pt, f, a)) { if (pthread_create(&a->thread, attr_pt, f, a)) {
free(a); free(a);
workers = tmp; workers = tmp;
return; return;
} }
} }
static void remove_worker(pthread_t th) static void remove_worker(pthread_t th)
{ {
skipping to change at line 700 skipping to change at line 735
add_worker(Burnworker_type_writE, d, add_worker(Burnworker_type_writE, d,
(WorkerFunc) write_disc_worker_func, &o); (WorkerFunc) write_disc_worker_func, &o);
ex:; ex:;
BURN_FREE_MEM(reasons); BURN_FREE_MEM(reasons);
} }
static void *fifo_worker_func(struct w_list *w) static void *fifo_worker_func(struct w_list *w)
{ {
int old;
#define Libburn_protect_fifo_threaD 1 #define Libburn_protect_fifo_threaD 1
#ifdef Libburn_protect_fifo_threaD #ifdef Libburn_protect_fifo_threaD
sigset_t sigset, oldset; sigset_t sigset, oldset;
/* Protect fifo thread from being interrupted by external signals */ /* Protect fifo thread from being interrupted by external signals */
sigfillset(&sigset); sigfillset(&sigset);
sigdelset(&sigset, SIGSEGV); sigdelset(&sigset, SIGSEGV);
sigdelset(&sigset, SIGILL); sigdelset(&sigset, SIGILL);
pthread_sigmask(SIG_SETMASK, &sigset, &oldset); pthread_sigmask(SIG_SETMASK, &sigset, &oldset);
#endif /* Libburn_protect_fifo_threaD */ #endif /* Libburn_protect_fifo_threaD */
pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, &old);
pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, &old);
/* 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 #ifdef Libburn_protect_fifo_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_fifo_threaD */ #endif /* Libburn_protect_fifo_threaD */
return NULL; return NULL;
} }
skipping to change at line 758 skipping to change at line 788
fs->is_started = 1; fs->is_started = 1;
return 1; return 1;
} }
int burn_fifo_abort(struct burn_source_fifo *fs, int flag) int burn_fifo_abort(struct burn_source_fifo *fs, int flag)
{ {
int ret; int ret;
pthread_t pt; pthread_t pt;
if (fs->thread_is_valid <= 0 || fs->thread_handle == NULL) burn_async_manage_lock(BURN_ASYNC_LOCK_OBTAIN);
return(2);
#ifdef NIX if (fs->thread_is_valid <= 0 || fs->thread_handle == NULL) {
libdax_msgs_submit(libdax_messenger, -1, 0x00000002, burn_async_manage_lock(BURN_ASYNC_LOCK_RELEASE);
LIBDAX_MSGS_SEV_DEBUG, LIBDAX_MSGS_PRIO_HIGH, return 2;
"Aborting running burn_source_fifo thread", 0, 0); }
#endif /* NIX */ pt = *((pthread_t *) fs->thread_handle);
burn_async_manage_lock(BURN_ASYNC_LOCK_RELEASE);
fs->do_abort = 1;
ret = pthread_join(pt, NULL);
pt= *((pthread_t *) fs->thread_handle);
remove_worker(pt);
ret = pthread_cancel(pt);
return (ret == 0); return (ret == 0);
} }
#ifdef Libburn_has_burn_async_join_alL #ifdef Libburn_has_burn_async_join_alL
/* ts A71019 : never used */ /* ts A71019 : never used */
void burn_async_join_all(void) void burn_async_join_all(void)
{ {
void *ret; void *ret;
 End of changes. 10 change blocks. 
25 lines changed or deleted 56 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)