You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by GitBox <gi...@apache.org> on 2022/02/08 09:10:34 UTC

[GitHub] [arrow] pitrou commented on a change in pull request #12358: ARROW-15593: [C++] Make after-fork ThreadPool reinitialization thread-safe

pitrou commented on a change in pull request #12358:
URL: https://github.com/apache/arrow/pull/12358#discussion_r801407952



##########
File path: cpp/src/arrow/util/mutex.cc
##########
@@ -50,5 +55,31 @@ Mutex::Guard Mutex::Lock() {
 
 Mutex::Mutex() : impl_(new Impl, [](Impl* impl) { delete impl; }) {}
 
+#ifndef _WIN32
+namespace {
+
+struct AfterForkState {
+  // A global instance that will also register the atfork handler when
+  // constructed.
+  static AfterForkState instance;
+
+  // The mutex may be used at shutdown, so make it eternal.
+  // The leak (only in child processes) is a small price to pay for robustness.
+  Mutex* mutex = nullptr;

Review comment:
       Just for the record, no process will be larger because of this leak. Perhaps I should have put "leak" in quotes, because regardless of using `unique_ptr` or not, the mutex will be destroyed at process exit. The difference is mainly in code hygiene, and also some sanitizers may report it as an actual leak (memory that wasn't deallocated before process exit).




-- 
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-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org