Skip to content

copy value of seq to the stack to avoid race condition when generating Job names#385

Merged
franku merged 1 commit intobareos:masterfrom
WaryWolf:fix-job-creation-racecond
Jan 3, 2020
Merged

copy value of seq to the stack to avoid race condition when generating Job names#385
franku merged 1 commit intobareos:masterfrom
WaryWolf:fix-job-creation-racecond

Conversation

@WaryWolf
Copy link

Fixes an issue where two jobs that were created at the same time could share a unique job name, which caused various issues.

Copy link
Contributor

@franku franku left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. However, would you mind to put your name on the AUTHORS list?
https://github.com/bareos/bareos/blob/master/AUTHORS

@WaryWolf WaryWolf force-pushed the fix-job-creation-racecond branch from a09da8f to 272f4f0 Compare January 2, 2020 00:22
@WaryWolf
Copy link
Author

WaryWolf commented Jan 3, 2020

Sorry, I seem to have messed something up by force-pushing the amended commit with the updated AUTHORS file. I can't see the changes you requested - hopefully the amended commit is what you wanted.

Have a good weekend!

@franku franku merged commit 472ceb9 into bareos:master Jan 3, 2020
franku added a commit that referenced this pull request Jan 3, 2020
copy value of seq to the stack to avoid race condition when generating Job names
franku added a commit that referenced this pull request Jan 3, 2020
(manual merge)
copy value of seq to the stack to avoid race condition when generating Job names
benibr pushed a commit to benibr/bareos that referenced this pull request Jan 9, 2020
  fixes bareos#385: bareos daemon stop restart hang if bareos-tray-monitor is connected

  The functionality was overengineered and did not do what it
  probably should do.

  The names workq or workqueue did not explain what the code
  actually did and it was not reliable.

  Therefore refactored the complete code:

- ThreadList is now a class that contains the calls to create
  worker-threads who will call a pre-defined handler routine
- ThreadListPrivate contains the implementation and is hidden from
  the public interface
- using ThreadList with RAII in the daemon code, accordingly
- the new functionality consists mainly of a list where new threads
  are added to, therefore the name of all files and variables
  are changed into names containing "thread list" or similar
- used std::thread instead of pthread
- used std::set instead of a linked list
- worker threads start detached and cleanup resources by themself

- removed or renamed variables
- removed unused code in the thread start and at the end
- previous return type of int was not used as intended,
  therefore a simple bool is enough
- upon shutdown threads are not joined but the parent thread will
  wait until the thread list is empty or a timeout occurs
- added a user callback for each worker-thread that is called from
  the parent thread before it enters the waiting state

- ua_server: close user_agent_socket only in FreeUaContext
- synchronize shutdown of worker threads on daemon shutdown
- updated code that calls the new functions accordingly

- fd and dir: added a worker-thread shutdown handler to each
  socket server
- sd: do not cleanup jcr memory of a console connection in the
  terminate handler
- dird: StopSocketServer is now called before StopWatchdog so
  socket operations still can time out
- set the timeout for the second call of SSL_shutdown from
  120 seconds to 2 seconds as this makes director shutdown
  faster

- added a unit test
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants