haiku/headers/private/app/RosterPrivate.h
Ingo Weinhold 6bfd06d1ff BRoster::Launch() eventually launches the application in question
in several steps:
1. early pre-registration with the registrar ("I wanna launch the
   app, make sure noone interferes.")
2. load the app image
3. finish pre-registration with the registrar ("I have launched
   the app, here is its team ID.")
4. start app main thread
5. send "on launch" messages to the app (argv, refs, others)

If the app is already running or being launched, 1. fails with a
conclusive error code and returns the team ID and the pre-registration
token of the app. Steps 2 - 4 are skipped and only the messages are
delivered using the team ID returned by 1.

This change fixes a race condition: The failed early pre-registration
request obviously cannot return the team ID, if the other thread
launching the app has not finished step 3 yet. Thus the argv/refs
message would not get delivered and Launch() would not return the
correct team ID.

Now we wait for the pre-registration to be finished in this case, using
the former _IsAppPreRegistered() mechanism, which already provided
such a waiting feature for one request. It has been extended to
accomodate an arbitrary number of waiting requests and renamed to
_IsAppRegistered().

This fixed bug #763.



git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@18728 a95241bf-73f2-0310-859d-f6bbb57e9c96
2006-08-31 17:54:16 +00:00

86 lines
2.4 KiB
C++

/*
* Copyright 2001-2006, Haiku.
* Distributed under the terms of the MIT License.
*
* Authors:
* Ingo Weinhold (bonefish@users.sf.net)
*/
#ifndef _ROSTER_PRIVATE_H
#define _ROSTER_PRIVATE_H
#include <Messenger.h>
#include <Roster.h>
class BRoster::Private {
public:
Private() : fRoster(const_cast<BRoster*>(be_roster)) {}
Private(BRoster &roster) : fRoster(&roster) {}
Private(BRoster *roster) : fRoster(roster) {}
void SetTo(BMessenger mainMessenger, BMessenger mimeMessenger);
status_t SendTo(BMessage *message, BMessage *reply, bool mime);
bool IsMessengerValid(bool mime) const;
status_t ShutDown(bool reboot, bool confirm, bool synchronous)
{ return fRoster->_ShutDown(reboot, confirm, synchronous); }
// needed by BApplication
status_t AddApplication(const char *mimeSig, const entry_ref *ref,
uint32 flags, team_id team, thread_id thread,
port_id port, bool fullReg, uint32 *token,
team_id *otherTeam) const
{ return fRoster->_AddApplication(mimeSig, ref, flags, team, thread,
port, fullReg, token, otherTeam); }
status_t SetSignature(team_id team, const char *mimeSig) const
{ return fRoster->_SetSignature(team, mimeSig); }
status_t CompleteRegistration(team_id team, thread_id thread,
port_id port) const
{ return fRoster->_CompleteRegistration(team, thread, port); }
status_t IsAppRegistered(const entry_ref *ref, team_id team,
uint32 token, bool *preRegistered, app_info *info) const
{ return fRoster->_IsAppRegistered(ref, team, token, preRegistered,
info); }
status_t RemoveApp(team_id team) const
{ return fRoster->_RemoveApp(team); }
// needed by GetRecentTester
void AddToRecentApps(const char *appSig) const
{ fRoster->_AddToRecentApps(appSig); }
void ClearRecentDocuments() const
{ fRoster->_ClearRecentDocuments(); }
void ClearRecentFolders() const
{ fRoster->_ClearRecentFolders(); }
void ClearRecentApps() const
{ fRoster->_ClearRecentApps(); }
void LoadRecentLists(const char *file) const
{ fRoster->_LoadRecentLists(file); }
void SaveRecentLists(const char *file) const
{ fRoster->_SaveRecentLists(file); }
// needed by the debug server
void ApplicationCrashed(team_id team) const
{ fRoster->_ApplicationCrashed(team); }
static void InitBeRoster();
static void DeleteBeRoster();
private:
BRoster *fRoster;
};
#endif // _ROSTER_PRIVATE_H