Please sign in to comment.
workq: refactor code or remove unneded code for worker threads
fixes #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
- Loading branch information...
Showing with 424 additions and 457 deletions.
- +2 −4 core/src/dird/dird.cc
- +6 −14 core/src/dird/jobq.cc
- +13 −3 core/src/dird/socket_server.cc
- +0 −1 core/src/dird/ua_server.cc
- +14 −3 core/src/filed/socket_server.cc
- +0 −1 core/src/include/jcr.h
- +4 −4 core/src/lib/CMakeLists.txt
- +23 −37 core/src/lib/bnet_server_tcp.cc
- +4 −2 core/src/lib/bnet_server_tcp.h
- +0 −1 core/src/lib/lib.h
- +151 −0 core/src/lib/thread_list.cc
- +59 −0 core/src/lib/thread_list.h
- +2 −2 core/src/lib/tls_openssl.cc
- +0 −273 core/src/lib/workq.cc
- +0 −76 core/src/lib/workq.h
- +10 −24 core/src/stored/ndmp_tape.cc
- +14 −3 core/src/stored/socket_server.cc
- +4 −9 core/src/stored/stored.cc
- +11 −0 core/src/tests/CMakeLists.txt
- +107 −0 core/src/tests/thread_list.cc
Oops, something went wrong.