Skip to content

Commit

Permalink
Close message stream early.
Browse files Browse the repository at this point in the history
For things like edit_job_codes() to work properly we should tear
down the message resource before we start tearing down the bits
and pieces of the JCR (and mig_jcr). Hopefully we don't trigger
to many deadlocks this way but this seems to be a severe design
flaw in which important state information is destroyed when you
might still want/need it.
  • Loading branch information
Marco van Wieringen committed Feb 17, 2015
1 parent 46f7f06 commit 6c0b2e5
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions src/dird/job.c
Expand Up @@ -494,15 +494,6 @@ static void *job_thread(void *arg)
Dmsg1(50, "======== End Job stat=%c ==========\n", jcr->JobStatus);
Dsm_check(100);

/*
* If we have a migration JCR now is the correct time to detach it
* as we are done running.
*/
if (jcr->mig_jcr) {
free_jcr(jcr->mig_jcr);
jcr->mig_jcr = NULL;
}

return NULL;
}

Expand Down Expand Up @@ -1311,6 +1302,19 @@ void dird_free_jcr(JCR *jcr)
{
Dmsg0(200, "Start dird free_jcr\n");

/*
* Close the messages for this Messages resource, which means to close
* any open files, and dispatch any pending email messages. We do this now
* that we still have all the info we need we start tearing down the jcr
* after this call.
*/
close_msg(jcr);

if (jcr->mig_jcr) {
free_jcr(jcr->mig_jcr);
jcr->mig_jcr = NULL;
}

dird_free_jcr_pointers(jcr);
if (jcr->term_wait_inited) {
pthread_cond_destroy(&jcr->term_wait);
Expand Down

0 comments on commit 6c0b2e5

Please sign in to comment.