framlog commented on a change in pull request #12350: URL: https://github.com/apache/arrow/pull/12350#discussion_r801184145
########## File path: cpp/src/arrow/util/thread_pool.cc ########## @@ -235,23 +235,32 @@ ThreadPool::~ThreadPool() { void ThreadPool::ProtectAgainstFork() { #ifndef _WIN32 pid_t current_pid = getpid(); - if (pid_ != current_pid) { - // Reinitialize internal state in child process after fork() - // Ideally we would use pthread_at_fork(), but that doesn't allow - // storing an argument, hence we'd need to maintain a list of all - // existing ThreadPools. - int capacity = state_->desired_capacity_; - - auto new_state = std::make_shared<ThreadPool::State>(); - new_state->please_shutdown_ = state_->please_shutdown_; - new_state->quick_shutdown_ = state_->quick_shutdown_; - - pid_ = current_pid; - sp_state_ = new_state; - state_ = sp_state_.get(); - + pid_t old_pid = pid_.load(); + int capacity = 0; + if (current_pid != old_pid) { + // FIXME: It may get deadlock here if users fork processes while the parent runs + // in the middle of resetting states. Review comment: Great. Feel free to close this then. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: github-unsubscr...@arrow.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org