Better handling of cancelation. Just join thread if image already consumed.
This commit is contained in:
parent
8930de4026
commit
3510f56966
@ -1095,15 +1095,21 @@ static off_t bs_get_size(struct burn_source *bs)
|
|||||||
|
|
||||||
static void bs_free_data(struct burn_source *bs)
|
static void bs_free_data(struct burn_source *bs)
|
||||||
{
|
{
|
||||||
|
int st;
|
||||||
Ecma119Image *target = (Ecma119Image*)bs->data;
|
Ecma119Image *target = (Ecma119Image*)bs->data;
|
||||||
|
|
||||||
/* forces writer to stop if it is still running */
|
st = iso_ring_buffer_get_status(bs, NULL, NULL);
|
||||||
iso_ring_buffer_reader_close(target->buffer, 0);
|
|
||||||
|
|
||||||
/* wait until writer thread finishes */
|
/* was read already finished (i.e, canceled)? */
|
||||||
pthread_join(target->wthread, NULL);
|
if (st < 4) {
|
||||||
|
/* forces writer to stop if it is still running */
|
||||||
iso_msg_debug(target->image->id, "Writer thread joined");
|
iso_ring_buffer_reader_close(target->buffer, 0);
|
||||||
|
|
||||||
|
/* wait until writer thread finishes */
|
||||||
|
pthread_join(target->wthread, NULL);
|
||||||
|
iso_msg_debug(target->image->id, "Writer thread joined");
|
||||||
|
}
|
||||||
|
|
||||||
iso_msg_debug(target->image->id,
|
iso_msg_debug(target->image->id,
|
||||||
"Ring buffer was %d times full and %d times empty",
|
"Ring buffer was %d times full and %d times empty",
|
||||||
iso_ring_buffer_get_times_full(target->buffer),
|
iso_ring_buffer_get_times_full(target->buffer),
|
||||||
@ -1116,12 +1122,21 @@ static void bs_free_data(struct burn_source *bs)
|
|||||||
static
|
static
|
||||||
int bs_cancel(struct burn_source *bs)
|
int bs_cancel(struct burn_source *bs)
|
||||||
{
|
{
|
||||||
|
int st;
|
||||||
|
size_t cap, free;
|
||||||
Ecma119Image *target = (Ecma119Image*)bs->data;
|
Ecma119Image *target = (Ecma119Image*)bs->data;
|
||||||
|
|
||||||
iso_msg_debug(target->image->id, "Reader thread being cancelled");
|
|
||||||
|
|
||||||
/* forces writer to stop if it is still running */
|
st = iso_ring_buffer_get_status(bs, &cap, &free);
|
||||||
iso_ring_buffer_reader_close(target->buffer, ISO_CANCELED);
|
|
||||||
|
if (free == cap && (st == 2 || st == 3)) {
|
||||||
|
/* image was already consumed */
|
||||||
|
iso_ring_buffer_reader_close(target->buffer, 0);
|
||||||
|
} else {
|
||||||
|
iso_msg_debug(target->image->id, "Reader thread being cancelled");
|
||||||
|
|
||||||
|
/* forces writer to stop if it is still running */
|
||||||
|
iso_ring_buffer_reader_close(target->buffer, ISO_CANCELED);
|
||||||
|
}
|
||||||
|
|
||||||
/* wait until writer thread finishes */
|
/* wait until writer thread finishes */
|
||||||
pthread_join(target->wthread, NULL);
|
pthread_join(target->wthread, NULL);
|
||||||
|
Loading…
Reference in New Issue
Block a user