Private class BAppServerLink now has a global locker, instead of

(ab)using the BApplication lock to synchronize messaging.
Also, it now has one global reply port, that is created on demand,
but never freed - hope this doesn't cause any other trouble.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@12957 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler 2005-06-04 17:16:49 +00:00
parent 3cd9c86453
commit 851fc4f198
2 changed files with 27 additions and 54 deletions

View File

@ -1,5 +1,5 @@
//------------------------------------------------------------------------------
// Copyright (c) 2001-2002, OpenBeOS
// Copyright (c) 2001-2005, Haiku
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
@ -26,38 +26,23 @@
// creating one locks the app_server connection; destroying one
// unlocks the connection.
//------------------------------------------------------------------------------
#ifndef APPSERVERLINK_H
#define APPSERVERLINK_H
// Standard Includes -----------------------------------------------------------
// System Includes -------------------------------------------------------------
// Project Includes ------------------------------------------------------------
#include <OS.h>
#include <PortLink.h>
// Local Includes --------------------------------------------------------------
// Local Defines ---------------------------------------------------------------
// Globals ---------------------------------------------------------------------
namespace BPrivate {
class BAppServerLink : public BPortLink
{
public:
BAppServerLink(void);
~BAppServerLink(void);
status_t FlushWithReply(int32 *code);
private:
port_id receiver;
class BAppServerLink : public BPortLink {
public:
BAppServerLink(void);
~BAppServerLink(void);
status_t FlushWithReply(int32 *code);
};
} // namespace BPrivate
#endif //APPSERVERLINK_H
#endif /* APPSERVERLINK_H */

View File

@ -1,5 +1,5 @@
//------------------------------------------------------------------------------
// Copyright (c) 2001-2002, OpenBeOS
// Copyright (c) 2001-2005, Haiku
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
@ -27,51 +27,47 @@
// unlocks the connection.
//------------------------------------------------------------------------------
// Standard Includes -----------------------------------------------------------
// System Includes -------------------------------------------------------------
#include <Application.h>
#include <Locker.h>
// Project Includes ------------------------------------------------------------
#include <AppServerLink.h>
// Local Includes --------------------------------------------------------------
// Local Defines ---------------------------------------------------------------
BLocker sLock;
port_id sReplyPort = -1;
// Globals ---------------------------------------------------------------------
namespace BPrivate {
BAppServerLink::BAppServerLink(void)
: BPortLink()
{
if (be_app)
{
be_app->Lock();
SetSendPort(be_app->fServerFrom);
}
receiver=create_port(100,"AppServerLink reply port");
SetReplyPort(receiver);
sLock.Lock();
// if there is no be_app, we can't do a whole lot, anyway
if (be_app)
SetSendPort(be_app->fServerFrom);
// There is only one global reply port, and we create it here
// (protected by sLock) when it's not yet there
if (sReplyPort < B_OK)
sReplyPort = create_port(100, "AppServerLink reply port");
SetReplyPort(sReplyPort);
}
//------------------------------------------------------------------------------
BAppServerLink::~BAppServerLink()
{
delete_port(receiver);
if (be_app)
be_app->Unlock();
sLock.Unlock();
}
//------------------------------------------------------------------------------
status_t BAppServerLink::FlushWithReply(int32 *code)
status_t
BAppServerLink::FlushWithReply(int32 *code)
{
status_t err;
err = Attach<port_id>(receiver);
err = Attach<port_id>(sReplyPort);
if (err < B_OK)
return err;
@ -83,11 +79,3 @@ status_t BAppServerLink::FlushWithReply(int32 *code)
}
} // namespace BPrivate
/*
* $Log $
*
* $Id $
*
*/