summaryrefslogtreecommitdiffstats
path: root/libhb/work.c
diff options
context:
space:
mode:
authorJohn Stebbins <[email protected]>2018-08-07 13:34:36 -0700
committerJohn Stebbins <[email protected]>2018-08-07 13:34:36 -0700
commitd80a17590a1aa6c65de0ef0f2e6e0bd273f4753e (patch)
tree9d12d136483ea460c1923cc8430d5c4ccdaef647 /libhb/work.c
parent1fbea6b770f6691d4a07b60d1e370fa70c483473 (diff)
fix race in getting sequence_id of completed job
The sequence_id was only available for the WORKING state and not the WORKDONE state. But frontends poll for status periodically and can miss all status updates for the WORKING state if the file is very short or an error occurs early during transcoding. When WORKING status is missed, there was no way to know the sequence_id associated with the WORKDONE status.
Diffstat (limited to 'libhb/work.c')
-rw-r--r--libhb/work.c27
1 files changed, 23 insertions, 4 deletions
diff --git a/libhb/work.c b/libhb/work.c
index 22825840a..ceb185783 100644
--- a/libhb/work.c
+++ b/libhb/work.c
@@ -77,6 +77,25 @@ static void InitWorkState(hb_handle_t *h, int pass_id, int pass, int pass_count)
}
+static void SetWorkdoneState(hb_job_t *job)
+{
+ hb_state_t state;
+
+
+ if (job == NULL)
+ {
+ return;
+ }
+ hb_get_state2(job->h, &state);
+
+ state.state = HB_STATE_WORKDONE;
+ state.param.working.error = *job->done_error;
+ state.param.working.sequence_id = job->sequence_id;
+
+ hb_set_state( job->h, &state );
+
+}
+
/**
* Iterates through job list and calls do_job for each job.
* @param _work Handle work object.
@@ -136,8 +155,10 @@ static void work_func( void * _work )
do_job( job );
*(work->current_job) = NULL;
}
- // Clean up any incomplete jobs
- for (; pass < pass_count; pass++)
+ SetWorkdoneState(job);
+
+ // Clean job passes
+ for (pass = 0; pass < pass_count; pass++)
{
job = hb_list_item(passes, pass);
hb_job_close(&job);
@@ -1854,8 +1875,6 @@ cleanup:
}
hb_buffer_pool_free();
-
- hb_job_close(&job);
}
static inline void copy_chapter( hb_buffer_t * dst, hb_buffer_t * src )