diff --git a/headers/private/app/LooperList.h b/headers/private/app/LooperList.h index 32b77a4c96..7bdc8244e4 100644 --- a/headers/private/app/LooperList.h +++ b/headers/private/app/LooperList.h @@ -41,6 +41,8 @@ public: BLooper* LooperForName(const char* name); BLooper* LooperForPort(port_id port); + void InitAfterFork(); + private: struct LooperData { LooperData(); diff --git a/headers/private/app/TokenSpace.h b/headers/private/app/TokenSpace.h index 97798e2a33..a3aacef566 100644 --- a/headers/private/app/TokenSpace.h +++ b/headers/private/app/TokenSpace.h @@ -51,6 +51,8 @@ public: status_t AcquireHandlerTarget(int32 token, BDirectMessageTarget** _target); + void InitAfterFork(); + private: struct token_info { int16 type; diff --git a/src/kits/app/InitTerminateLibBe.cpp b/src/kits/app/InitTerminateLibBe.cpp index 1d4b527959..6d5b017523 100644 --- a/src/kits/app/InitTerminateLibBe.cpp +++ b/src/kits/app/InitTerminateLibBe.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2001-2009, Haiku. + * Copyright 2001-2011, Haiku. * Distributed under the terms of the MIT License. * * Authors: @@ -12,8 +12,10 @@ #include #include +#include #include #include +#include // debugging @@ -28,6 +30,8 @@ initialize_forked_child() DBG(OUT("initialize_forked_child()\n")); BMessage::Private::StaticReInitForkedChild(); + BPrivate::gLooperList.InitAfterFork(); + BPrivate::gDefaultTokens.InitAfterFork(); DBG(OUT("initialize_forked_child() done\n")); } diff --git a/src/kits/app/LooperList.cpp b/src/kits/app/LooperList.cpp index f8844a2451..e27460a646 100644 --- a/src/kits/app/LooperList.cpp +++ b/src/kits/app/LooperList.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2001-2010, Haiku. + * Copyright 2001-2011, Haiku. * Distributed under the terms of the MIT License. * * Authors: @@ -187,6 +187,14 @@ BLooperList::LooperForPort(port_id port) } +void +BLooperList::InitAfterFork() +{ + // We need to reinitialize the locker to get a new semaphore + new (&fLock) BLocker("BLooperList lock"); +} + + bool BLooperList::EmptySlotPred(LooperData& data) { diff --git a/src/kits/app/TokenSpace.cpp b/src/kits/app/TokenSpace.cpp index 2ab3f85ea6..d1dec451a6 100644 --- a/src/kits/app/TokenSpace.cpp +++ b/src/kits/app/TokenSpace.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2001-2009, Haiku. + * Copyright 2001-2011, Haiku. * Distributed under the terms of the MIT License. * * Authors: @@ -169,4 +169,13 @@ BTokenSpace::AcquireHandlerTarget(int32 token, BDirectMessageTarget** _target) return B_OK; } + +void +BTokenSpace::InitAfterFork() +{ + // We need to reinitialize the locker to get a new semaphore + new (this) BTokenSpace(); +} + + } // namespace BPrivate