Cancelling libburn fifo thread before freeing the fifo object
This commit is contained in:
parent
6053f3a6e3
commit
6fe53827da
@ -1 +1 @@
|
||||
#define Cdrskin_timestamP "2008.11.08.134828"
|
||||
#define Cdrskin_timestamP "2008.11.08.141734"
|
||||
|
@ -25,9 +25,9 @@
|
||||
#include "drive.h"
|
||||
#include "write.h"
|
||||
#include "options.h"
|
||||
#include "file.h"
|
||||
#include "async.h"
|
||||
#include "init.h"
|
||||
#include "file.h"
|
||||
#include "back_hacks.h"
|
||||
|
||||
#include <pthread.h>
|
||||
@ -518,6 +518,12 @@ void burn_disc_write(struct burn_write_opts *opts, struct burn_disc *disc)
|
||||
|
||||
static void *fifo_worker_func(struct w_list *w)
|
||||
{
|
||||
int old;
|
||||
|
||||
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);
|
||||
remove_worker(pthread_self());
|
||||
return NULL;
|
||||
@ -547,6 +553,24 @@ int burn_fifo_start(struct burn_source *source, int flag)
|
||||
}
|
||||
|
||||
|
||||
int burn_fifo_abort(struct burn_source_fifo *fs, int flag)
|
||||
{
|
||||
int ret;
|
||||
pthread_t pt;
|
||||
|
||||
if (fs->thread_is_valid <= 0 || fs->thread_handle == NULL)
|
||||
return(2);
|
||||
|
||||
libdax_msgs_submit(libdax_messenger, -1, 0x00000002,
|
||||
LIBDAX_MSGS_SEV_DEBUG, LIBDAX_MSGS_PRIO_HIGH,
|
||||
"Aborting running burn_source_fifo thread", 0, 0);
|
||||
pt= *((pthread_t *) fs->thread_handle);
|
||||
remove_worker(pt);
|
||||
ret = pthread_cancel(pt);
|
||||
return (ret == 0);
|
||||
}
|
||||
|
||||
|
||||
#ifdef Libburn_has_burn_async_join_alL
|
||||
|
||||
/* ts A71019 : never used */
|
||||
|
@ -9,6 +9,8 @@
|
||||
#include <unistd.h>
|
||||
#include <fcntl.h>
|
||||
#include <time.h>
|
||||
#include <pthread.h>
|
||||
|
||||
#include "source.h"
|
||||
#include "libburn.h"
|
||||
#include "file.h"
|
||||
@ -307,6 +309,7 @@ static void fifo_free(struct burn_source *source)
|
||||
{
|
||||
struct burn_source_fifo *fs = source->data;
|
||||
|
||||
burn_fifo_abort(fs, 0);
|
||||
if (fs->inp != NULL)
|
||||
burn_source_free(fs->inp);
|
||||
if (fs->buf != NULL)
|
||||
@ -320,9 +323,12 @@ int burn_fifo_source_shoveller(struct burn_source *source, int flag)
|
||||
struct burn_source_fifo *fs = source->data;
|
||||
int ret, bufsize, diff, wpos, rpos, trans_end, free_bytes;
|
||||
char *bufpt;
|
||||
pthread_t thread_handle_storage;
|
||||
|
||||
fs->thread_handle= &thread_handle_storage;
|
||||
*((pthread_t *) fs->thread_handle)= pthread_self();
|
||||
fs->thread_pid = getpid();
|
||||
fs->thread_pid_valid = 1;
|
||||
fs->thread_is_valid = 1;
|
||||
|
||||
bufsize = fs->chunksize * fs->chunks;
|
||||
while (!fs->end_of_consumption) {
|
||||
@ -430,6 +436,8 @@ int burn_fifo_source_shoveller(struct burn_source *source, int flag)
|
||||
free(fs->buf); /* Give up fifo buffer. Next fifo might start soon. */
|
||||
fs->buf = NULL;
|
||||
|
||||
fs->thread_handle= NULL;
|
||||
fs->thread_is_valid = 0;
|
||||
return (fs->input_error == 0);
|
||||
}
|
||||
|
||||
@ -465,8 +473,9 @@ struct burn_source *burn_fifo_source_new(struct burn_source *inp,
|
||||
if (fs == NULL)
|
||||
return NULL;
|
||||
fs->is_started = 0;
|
||||
fs->thread_handle = NULL;
|
||||
fs->thread_pid = 0;
|
||||
fs->thread_pid_valid = 0;
|
||||
fs->thread_is_valid = 0;
|
||||
fs->inp = NULL; /* set later */
|
||||
fs->chunksize = chunksize;
|
||||
fs->chunks = chunks;
|
||||
|
@ -29,8 +29,9 @@ struct burn_source_fifo {
|
||||
*/
|
||||
int is_started;
|
||||
|
||||
void *thread_handle; /* actually a pointer to a thread_t */
|
||||
int thread_pid;
|
||||
int thread_pid_valid;
|
||||
int thread_is_valid;
|
||||
|
||||
/* the burn_source for which this fifo is acting as proxy */
|
||||
struct burn_source *inp;
|
||||
|
Loading…
Reference in New Issue
Block a user