Net_server starts services by invoking fork() followed by exec(). If the latter fails (for instance because the service isn't installed), the forked child is invoking exit(). This in turn unloads libbe, triggering static cleanup code in BMessage, which deletes a couple of message ports that were inherited from the parent during the fork. After that, net_server was desparately missing those ports and no longer worked reliably. * in InitTerminateLibBe, we now register an atfork-(child-)handler, which takes care to re-initialize the static reply ports used by BMessage code * added BMessage::Private::StaticReInitForkedChild wrapper and BMessage::_StaticReInitForkedChild() implementation which overwrites the inherited port IDs with a set of own ports git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@33050 a95241bf-73f2-0310-859d-f6bbb57e9c96
75 lines
1.2 KiB
C++
75 lines
1.2 KiB
C++
/*
|
|
* Copyright 2001-2005, Haiku.
|
|
* Distributed under the terms of the MIT License.
|
|
*
|
|
* Authors:
|
|
* Ingo Weinhold ([email protected])
|
|
*/
|
|
|
|
//! Global library initialization/termination routines.
|
|
|
|
|
|
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
|
|
#include <ClipboardPrivate.h>
|
|
#include <MessagePrivate.h>
|
|
#include <RosterPrivate.h>
|
|
|
|
|
|
// debugging
|
|
//#define DBG(x) x
|
|
#define DBG(x)
|
|
#define OUT printf
|
|
|
|
|
|
static void
|
|
initialize_forked_child()
|
|
{
|
|
DBG(OUT("initialize_forked_child()\n"));
|
|
|
|
BMessage::Private::StaticReInitForkedChild();
|
|
|
|
DBG(OUT("initialize_forked_child() done\n"));
|
|
}
|
|
|
|
|
|
extern "C" void
|
|
initialize_before()
|
|
{
|
|
DBG(OUT("initialize_before()\n"));
|
|
|
|
BMessage::Private::StaticInit();
|
|
BRoster::Private::InitBeRoster();
|
|
|
|
atfork(initialize_forked_child);
|
|
|
|
DBG(OUT("initialize_before() done\n"));
|
|
}
|
|
|
|
|
|
extern "C" void
|
|
initialize_after()
|
|
{
|
|
DBG(OUT("initialize_after()\n"));
|
|
|
|
BPrivate::init_clipboard();
|
|
// needs to send a message, and that requires gDefaultTokens to be initialized
|
|
|
|
DBG(OUT("initialize_after() done\n"));
|
|
}
|
|
|
|
|
|
extern "C" void
|
|
terminate_after()
|
|
{
|
|
DBG(OUT("terminate_after()\n"));
|
|
|
|
BRoster::Private::DeleteBeRoster();
|
|
BMessage::Private::StaticCleanup();
|
|
BMessage::Private::StaticCacheCleanup();
|
|
|
|
DBG(OUT("terminate_after() done\n"));
|
|
}
|
|
|