mirror of
https://github.com/Zygo/bees.git
synced 2025-06-17 01:56:16 +02:00
context: get rid of all instances of pthread_cancel
pthread_cancel doesn't really work properly. It was only being used in bees to bring threads to a stop if the BeesContext is destroyed early. It is frequently implicated in core dump reports because of the fragility of the C++ iostream / C stdio / library infrastructure, particularly surrounding upgrades on the host running bees. The pthread_cancel call itself often simply fails even when it doesn't call terminate(). Defer creation of the status and progress threads until after the BeesContext::start method is invoked. At that point, the existing ask-threads-nicely-to-stop code is up and running, and normal condvars can be used to bring bees to a stop, without having to resort to pthread_cancel. Since we're deleting half of the BeesContext constructor in this change, let's remove the other half too, and put an end to the deprecated support for multiple BeesContexts sharing a process. It's still possible to run multiple BeesContexts, but they will not share a FD cache. This will allow the FD cache's keys to become smaller and hopefully save some memory later on. Fixes: #171 Signed-off-by: Zygo Blaxell <bees@furryterror.org>
This commit is contained in:
@ -751,8 +751,8 @@ class BeesContext : public enable_shared_from_this<BeesContext> {
|
||||
condition_variable m_abort_condvar;
|
||||
bool m_abort_requested = false;
|
||||
|
||||
BeesThread m_progress_thread;
|
||||
BeesThread m_status_thread;
|
||||
shared_ptr<BeesThread> m_progress_thread;
|
||||
shared_ptr<BeesThread> m_status_thread;
|
||||
|
||||
void set_root_fd(Fd fd);
|
||||
|
||||
@ -763,7 +763,7 @@ class BeesContext : public enable_shared_from_this<BeesContext> {
|
||||
void rewrite_file_range(const BeesFileRange &bfr);
|
||||
|
||||
public:
|
||||
BeesContext(shared_ptr<BeesContext> parent_ctx = nullptr);
|
||||
BeesContext() = default;
|
||||
|
||||
void set_root_path(string path);
|
||||
|
||||
|
Reference in New Issue
Block a user