bareos: master 1519b1fa

Author Committer Branch Timestamp Parent
Sebastian Sura Sebastian Sura master 2023-11-08 15:19 master d4861da2 Pending
Changeset copy-thread: fix thread related issues

The general gist before was this:

* copy thread:
- Wait for start
- Wait for dequeue
  - if data: handle data; loop
  - if no data: break inner (this only happens on flush)
- `signal` that queue was fushed and that the thread is waiting
  for work
- goto begin
* main thread
- do some setup
- start enqueueing data; signal start to thread if not started
  (this was done with an unsynchronized read!)
- flush when done
- During cleanup, cancel the thread while it is waiting on a
  start signal.
with some locks & unlocks sprinkled in. One should note that the
cleanup copy thread callback always unlockes the lock regardless of
whether the copy thread locked the mutex or not!

This was slightly changed:
* Clearly there is no need to wait for "start" at all, since we wait on
  the dequeue anyways -- so this was removed.
* Instead of just canceling the thread, we set a flag that tells the
  Copythread to exit, which the thread checks after every flush. As
  such we also make sure flush the queue on cleanup.
* We also now properly initialize all thread_context members!
mod - core/src/vmware/vadp_dumper/copy_thread.cc Diff File
mod - core/src/vmware/vadp_dumper/copy_thread.h Diff File