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:
@@ -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
|
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||||
// copy of this software and associated documentation files (the "Software"),
|
// copy of this software and associated documentation files (the "Software"),
|
||||||
@@ -26,38 +26,23 @@
|
|||||||
// creating one locks the app_server connection; destroying one
|
// creating one locks the app_server connection; destroying one
|
||||||
// unlocks the connection.
|
// unlocks the connection.
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
|
|
||||||
#ifndef APPSERVERLINK_H
|
#ifndef APPSERVERLINK_H
|
||||||
#define APPSERVERLINK_H
|
#define APPSERVERLINK_H
|
||||||
|
|
||||||
// Standard Includes -----------------------------------------------------------
|
|
||||||
|
|
||||||
// System Includes -------------------------------------------------------------
|
|
||||||
|
|
||||||
// Project Includes ------------------------------------------------------------
|
|
||||||
#include <OS.h>
|
|
||||||
#include <PortLink.h>
|
#include <PortLink.h>
|
||||||
|
|
||||||
// Local Includes --------------------------------------------------------------
|
|
||||||
|
|
||||||
// Local Defines ---------------------------------------------------------------
|
|
||||||
|
|
||||||
// Globals ---------------------------------------------------------------------
|
|
||||||
|
|
||||||
|
|
||||||
namespace BPrivate {
|
namespace BPrivate {
|
||||||
|
|
||||||
class BAppServerLink : public BPortLink
|
class BAppServerLink : public BPortLink {
|
||||||
{
|
public:
|
||||||
public:
|
BAppServerLink(void);
|
||||||
BAppServerLink(void);
|
~BAppServerLink(void);
|
||||||
~BAppServerLink(void);
|
|
||||||
status_t FlushWithReply(int32 *code);
|
status_t FlushWithReply(int32 *code);
|
||||||
private:
|
|
||||||
port_id receiver;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace BPrivate
|
} // namespace BPrivate
|
||||||
|
|
||||||
#endif //APPSERVERLINK_H
|
#endif /* APPSERVERLINK_H */
|
||||||
|
|
||||||
|
|||||||
@@ -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
|
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||||
// copy of this software and associated documentation files (the "Software"),
|
// copy of this software and associated documentation files (the "Software"),
|
||||||
@@ -27,51 +27,47 @@
|
|||||||
// unlocks the connection.
|
// unlocks the connection.
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
|
|
||||||
// Standard Includes -----------------------------------------------------------
|
|
||||||
|
|
||||||
// System Includes -------------------------------------------------------------
|
|
||||||
#include <Application.h>
|
#include <Application.h>
|
||||||
|
#include <Locker.h>
|
||||||
|
|
||||||
// Project Includes ------------------------------------------------------------
|
|
||||||
#include <AppServerLink.h>
|
#include <AppServerLink.h>
|
||||||
|
|
||||||
// Local Includes --------------------------------------------------------------
|
|
||||||
|
|
||||||
// Local Defines ---------------------------------------------------------------
|
BLocker sLock;
|
||||||
|
port_id sReplyPort = -1;
|
||||||
|
|
||||||
// Globals ---------------------------------------------------------------------
|
|
||||||
|
|
||||||
namespace BPrivate {
|
namespace BPrivate {
|
||||||
|
|
||||||
BAppServerLink::BAppServerLink(void)
|
BAppServerLink::BAppServerLink(void)
|
||||||
: BPortLink()
|
|
||||||
{
|
{
|
||||||
if (be_app)
|
sLock.Lock();
|
||||||
{
|
|
||||||
be_app->Lock();
|
|
||||||
SetSendPort(be_app->fServerFrom);
|
|
||||||
}
|
|
||||||
receiver=create_port(100,"AppServerLink reply port");
|
|
||||||
SetReplyPort(receiver);
|
|
||||||
|
|
||||||
|
// 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()
|
BAppServerLink::~BAppServerLink()
|
||||||
{
|
{
|
||||||
delete_port(receiver);
|
sLock.Unlock();
|
||||||
if (be_app)
|
|
||||||
be_app->Unlock();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
status_t BAppServerLink::FlushWithReply(int32 *code)
|
status_t
|
||||||
|
BAppServerLink::FlushWithReply(int32 *code)
|
||||||
{
|
{
|
||||||
status_t err;
|
status_t err;
|
||||||
|
|
||||||
err = Attach<port_id>(receiver);
|
err = Attach<port_id>(sReplyPort);
|
||||||
if (err < B_OK)
|
if (err < B_OK)
|
||||||
return err;
|
return err;
|
||||||
|
|
||||||
@@ -83,11 +79,3 @@ status_t BAppServerLink::FlushWithReply(int32 *code)
|
|||||||
}
|
}
|
||||||
|
|
||||||
} // namespace BPrivate
|
} // namespace BPrivate
|
||||||
|
|
||||||
/*
|
|
||||||
* $Log $
|
|
||||||
*
|
|
||||||
* $Id $
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user