On Wednesday 22 August 2007 22:07, Allan Black wrote:
> Kern Sibbald wrote:
> > 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.
>
> OK.
>
> Actually, that's quite interesting .... in the current (unpatched) code,
> last_jobs is updated in free_common_jcr(), which is called from free_jcr()
> a few lines below the call of unlock_jcr_chain() .... so does that mean
> the code to update last_jobs has the same problem? 

That is quite possible. I would have to examine the code more carefully.  
However, even if that is the case, the window for race conditions is very 
tiny.  Once you start deleting and rewriting the file, the window as is the 
case in the write_state_file() code, the window becomes enormous.

> dlists don't seem to have their own locks.
>
> In addition, as you note, you need to do
>
> > something so that the state file is not updated more frequently than
> > really necessary.
>
> Yes, now I think about it, I can see how to do that quite easily.

I imagine (but would really need to check the code) that you could probably 
just exclude any jobs with JobId=0.  I just looked at the code quickly, so 
this may already be done.

By the way, the best way to provide a patch is to send a single patch file 
that is generated by:

  svn checkout ... (see developers guide for exact syntax)
  (make your changes ...)
  (test ...)
   svn update
   (correct any eventual conflicts ...)
   svn diff >state-file.patch
   (look at state-file.patch to ensure it is correct, complete and
    doesn't have any extra "garbage", but don't change it)
   (send state-file.patch ...)
   
  

>
> Allan
>
> > 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.
>
> -------------------------------------------------------------------------
> 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

-------------------------------------------------------------------------
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