As it stands, the current patch that you have submitted will not work 
correctly since two threads can be terminating at the same time, and the 
write_state_file() code is not thread safe.   You can probably correct it by 
moving the jcr chain lock.  In addition, as you note, you need to do 
something so that the state file is not updated more frequently than really 
necessary.

On Wednesday 22 August 2007 14:17, Allan Black wrote:
> - Can we write the state file after every job terminates? On Win32
>   the system crashes and the state file is not updated.
>
> Not just on Win32 :-) I have a similar problem sometimes, because I
> don't live in a large town and I don't have a UPS.
>
> I've changed the lib code and the three daemons, so that each state
> file gets updated at the end of every job.
>
> What I had to do was:
>
> 1) Update the functions free_common_jcr and free_jcr in lib/jcr.c, to
>    move the code which updates last_job. This code was originally in
>    free_common_jcr, and I moved it to free_jcr, so that it would be
>    executed earlier in the process. last_job needs to be updated
>    before the call of jcr->daemon_free_jcr(jcr); -- see 2) below.
>
>    [free_common_jcr is only ever called from free_jcr]
>
> 2) Add a call to write_state_file() to each of the daemons' own
>    free_jcr functions (dird_free_jcr, stored_free_jcr, filed_free_jcr)
>    so that the daemon will update its state file immediately after
>    free_jcr has updated last_job.
>
> I've used this patch on 2.0.2 for several months, and on 2.2.0 for
> a week or two now, with no problems. I've attached the patch (diff -u)
> as four separate xxx.c.patch files.
>
> However, it's not perfect - the state file is updated at the end of
> *every* job, which means that exiting bat, bconsole etc. causes the
> state file to be written.
>
> Allan

-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >>  http://get.splunk.com/
_______________________________________________
Bacula-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bacula-devel

Reply via email to