Author: axeld Date: 2011-10-29 23:17:59 +0200 (Sat, 29 Oct 2011) New Revision: 42982 Changeset: https://dev.haiku-os.org/changeset/42982 Ticket: https://dev.haiku-os.org/ticket/5668 Modified: haiku/trunk/headers/private/app/LooperList.h haiku/trunk/headers/private/app/TokenSpace.h haiku/trunk/src/kits/app/InitTerminateLibBe.cpp haiku/trunk/src/kits/app/LooperList.cpp haiku/trunk/src/kits/app/TokenSpace.cpp Log: * Reinitialize global locks after a fork (at least those in the Application Kit). * This should fix #5668. Modified: haiku/trunk/headers/private/app/LooperList.h =================================================================== --- haiku/trunk/headers/private/app/LooperList.h 2011-10-29 21:04:22 UTC (rev 42981) +++ haiku/trunk/headers/private/app/LooperList.h 2011-10-29 21:17:59 UTC (rev 42982) @@ -41,6 +41,8 @@ BLooper* LooperForName(const char* name); BLooper* LooperForPort(port_id port); + void InitAfterFork(); + private: struct LooperData { LooperData(); Modified: haiku/trunk/headers/private/app/TokenSpace.h =================================================================== --- haiku/trunk/headers/private/app/TokenSpace.h 2011-10-29 21:04:22 UTC (rev 42981) +++ haiku/trunk/headers/private/app/TokenSpace.h 2011-10-29 21:17:59 UTC (rev 42982) @@ -51,6 +51,8 @@ status_t AcquireHandlerTarget(int32 token, BDirectMessageTarget** _target); + void InitAfterFork(); + private: struct token_info { int16 type; Modified: haiku/trunk/src/kits/app/InitTerminateLibBe.cpp =================================================================== --- haiku/trunk/src/kits/app/InitTerminateLibBe.cpp 2011-10-29 21:04:22 UTC (rev 42981) +++ haiku/trunk/src/kits/app/InitTerminateLibBe.cpp 2011-10-29 21:17:59 UTC (rev 42982) @@ -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 <stdio.h> #include <stdlib.h> +#include <LooperList.h> #include <MessagePrivate.h> #include <RosterPrivate.h> +#include <TokenSpace.h> // debugging @@ -28,6 +30,8 @@ DBG(OUT("initialize_forked_child()\n")); BMessage::Private::StaticReInitForkedChild(); + BPrivate::gLooperList.InitAfterFork(); + BPrivate::gDefaultTokens.InitAfterFork(); DBG(OUT("initialize_forked_child() done\n")); } Modified: haiku/trunk/src/kits/app/LooperList.cpp =================================================================== --- haiku/trunk/src/kits/app/LooperList.cpp 2011-10-29 21:04:22 UTC (rev 42981) +++ haiku/trunk/src/kits/app/LooperList.cpp 2011-10-29 21:17:59 UTC (rev 42982) @@ -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 @@ } +void +BLooperList::InitAfterFork() +{ + // We need to reinitialize the locker to get a new semaphore + new (&fLock) BLocker("BLooperList lock"); +} + + bool BLooperList::EmptySlotPred(LooperData& data) { Modified: haiku/trunk/src/kits/app/TokenSpace.cpp =================================================================== --- haiku/trunk/src/kits/app/TokenSpace.cpp 2011-10-29 21:04:22 UTC (rev 42981) +++ haiku/trunk/src/kits/app/TokenSpace.cpp 2011-10-29 21:17:59 UTC (rev 42982) @@ -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 @@ return B_OK; } + +void +BTokenSpace::InitAfterFork() +{ + // We need to reinitialize the locker to get a new semaphore + new (this) BTokenSpace(); +} + + } // namespace BPrivate