Added global app_server port, so that other parts of the server don't have
to search for it. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@12859 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
a4ad43aa83
commit
2724858b5b
@ -73,6 +73,8 @@
|
||||
|
||||
Desktop *desktop;
|
||||
|
||||
port_id gAppServerPort;
|
||||
|
||||
// TODO: Global ? Is it really needed ?
|
||||
//! Used to access the app_server from new_decorator
|
||||
AppServer *app_server=NULL;
|
||||
@ -100,23 +102,25 @@ AppServer::AppServer(void) :
|
||||
fMessagePort = create_port(200, SERVER_PORT_NAME);
|
||||
if (fMessagePort == B_NO_MORE_PORTS)
|
||||
debugger("app_server could not create message port");
|
||||
|
||||
|
||||
gAppServerPort = fMessagePort;
|
||||
|
||||
// Create the input port. The input_server will send it's messages here.
|
||||
// TODO: If we want multiple user support we would need an individual
|
||||
// port for each user and do the following for each RootLayer.
|
||||
fServerInputPort = create_port(200, SERVER_INPUT_PORT);
|
||||
if (fServerInputPort == B_NO_MORE_PORTS)
|
||||
debugger("app_server could not create input port");
|
||||
|
||||
fAppList= new BList();
|
||||
fQuittingServer= false;
|
||||
make_decorator= NULL;
|
||||
|
||||
|
||||
fAppList = new BList();
|
||||
fQuittingServer = false;
|
||||
make_decorator = NULL;
|
||||
|
||||
// We need this in order for new_decorator to be able to instantiate new decorators
|
||||
app_server=this;
|
||||
app_server = this;
|
||||
|
||||
// Create the font server and scan the proper directories.
|
||||
fontserver=new FontServer;
|
||||
fontserver = new FontServer;
|
||||
fontserver->Lock();
|
||||
|
||||
// Used for testing purposes
|
||||
@ -168,37 +172,36 @@ AppServer::AppServer(void) :
|
||||
}
|
||||
|
||||
fontserver->Unlock();
|
||||
|
||||
|
||||
|
||||
// Load the GUI colors here and set the global set to the values contained therein. If this
|
||||
// is not possible, set colors to the defaults
|
||||
if(!LoadGUIColors(&gui_colorset))
|
||||
if (!LoadGUIColors(&gui_colorset))
|
||||
gui_colorset.SetToDefaults();
|
||||
|
||||
InitDecorators();
|
||||
|
||||
// Set up the Desktop
|
||||
desktop= new Desktop();
|
||||
desktop = new Desktop();
|
||||
desktop->Init();
|
||||
|
||||
// Create the bitmap allocator. Object declared in BitmapManager.cpp
|
||||
bitmapmanager= new BitmapManager();
|
||||
bitmapmanager = new BitmapManager();
|
||||
|
||||
// This is necessary to mediate access between the Poller and app_server threads
|
||||
fActiveAppLock= create_sem(1,"app_server_active_sem");
|
||||
fActiveAppLock = create_sem(1,"app_server_active_sem");
|
||||
|
||||
// This locker is for app_server and Picasso to vy for control of the ServerApp list
|
||||
fAppListLock= create_sem(1,"app_server_applist_sem");
|
||||
fAppListLock = create_sem(1,"app_server_applist_sem");
|
||||
|
||||
// This locker is to mediate access to the make_decorator pointer
|
||||
fDecoratorLock= create_sem(1,"app_server_decor_sem");
|
||||
|
||||
fDecoratorLock = create_sem(1,"app_server_decor_sem");
|
||||
|
||||
// Spawn our thread-monitoring thread
|
||||
fPicassoThreadID= spawn_thread(PicassoThread,"picasso", B_NORMAL_PRIORITY, this);
|
||||
fPicassoThreadID = spawn_thread(PicassoThread, "picasso", B_NORMAL_PRIORITY, this);
|
||||
if (fPicassoThreadID >= 0)
|
||||
resume_thread(fPicassoThreadID);
|
||||
|
||||
fDecoratorName="Default";
|
||||
fDecoratorName ="Default";
|
||||
|
||||
#if 0
|
||||
LaunchCursorThread();
|
||||
@ -878,6 +881,10 @@ AppServer::FindApp(const char *sig)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
// #pragma mark -
|
||||
|
||||
|
||||
/*!
|
||||
\brief Creates a new decorator instance
|
||||
\param rect Frame size
|
||||
@ -919,7 +926,7 @@ int
|
||||
main(int argc, char** argv)
|
||||
{
|
||||
// There can be only one....
|
||||
if (find_port(SERVER_PORT_NAME) != B_NAME_NOT_FOUND)
|
||||
if (find_port(SERVER_PORT_NAME) >= B_OK)
|
||||
return -1;
|
||||
|
||||
srand(real_time_clock_usecs());
|
||||
|
@ -1,5 +1,11 @@
|
||||
#ifndef _OPENBEOS_APP_SERVER_H_
|
||||
#define _OPENBEOS_APP_SERVER_H_
|
||||
/*
|
||||
* Copyright (c) 2001-2005, Haiku, Inc.
|
||||
* Distributed under the terms of the MIT license.
|
||||
*
|
||||
* Author: DarkWyrm <bpmagic@columbus.rr.com>
|
||||
*/
|
||||
#ifndef _HAIKU_APP_SERVER_H_
|
||||
#define _HAIKU_APP_SERVER_H_
|
||||
|
||||
#include <OS.h>
|
||||
#include <Locker.h>
|
||||
@ -26,10 +32,10 @@ class BitmapManager;
|
||||
application start and quit messages. It also starts the housekeeping threads
|
||||
and initializes most of the server's globals.
|
||||
*/
|
||||
#if TEST_MODE
|
||||
class AppServer : public BApplication
|
||||
#else
|
||||
|
||||
class AppServer
|
||||
#if TEST_MODE
|
||||
: public BApplication
|
||||
#endif
|
||||
{
|
||||
public:
|
||||
@ -94,5 +100,6 @@ Decorator *new_decorator(BRect rect, const char *title, int32 wlook, int32 wfeel
|
||||
extern BitmapManager *bitmapmanager;
|
||||
extern ColorSet gui_colorset;
|
||||
extern AppServer *app_server;
|
||||
extern port_id gAppServerPort;
|
||||
|
||||
#endif
|
||||
#endif /* _HAIKU_APP_SERVER_H_ */
|
||||
|
@ -216,12 +216,7 @@ ServerApp::PingTarget(void)
|
||||
{
|
||||
team_info tinfo;
|
||||
if (get_team_info(fClientTeamID,&tinfo) == B_BAD_TEAM_ID) {
|
||||
port_id serverport = find_port(SERVER_PORT_NAME);
|
||||
if (serverport == B_NAME_NOT_FOUND) {
|
||||
printf("PANIC: ServerApp %s could not find the app_server port in PingTarget()!\n",fSignature.String());
|
||||
return false;
|
||||
}
|
||||
fMsgSender->SetPort(serverport);
|
||||
fMsgSender->SetPort(gAppServerPort);
|
||||
fMsgSender->StartMessage(AS_DELETE_APP);
|
||||
fMsgSender->Attach(&fMonitorThreadID, sizeof(thread_id));
|
||||
fMsgSender->Flush();
|
||||
@ -308,12 +303,7 @@ ServerApp::MonitorApp(void *data)
|
||||
STRACE(("ServerApp::MonitorApp(): GetNextMessage returned %s\n", strerror(err)));
|
||||
|
||||
// ToDo: this should kill the app, but it doesn't work
|
||||
port_id serverport = find_port(SERVER_PORT_NAME);
|
||||
if (serverport == B_NAME_NOT_FOUND){
|
||||
printf("PANIC: ServerApp %s could not find the app_server port!\n",app->fSignature.String());
|
||||
break;
|
||||
}
|
||||
app->fMsgSender->SetPort(serverport);
|
||||
app->fMsgSender->SetPort(gAppServerPort);
|
||||
app->fMsgSender->StartMessage(AS_DELETE_APP);
|
||||
app->fMsgSender->Attach(&app->fMonitorThreadID, sizeof(thread_id));
|
||||
app->fMsgSender->Flush();
|
||||
@ -393,12 +383,7 @@ ServerApp::MonitorApp(void *data)
|
||||
STRACE(("ServerApp %s: B_QUIT_REQUESTED\n",app->fSignature.String()));
|
||||
// Our BApplication sent us this message when it quit.
|
||||
// We need to ask the app_server to delete ourself.
|
||||
port_id serverport = find_port(SERVER_PORT_NAME);
|
||||
if (serverport == B_NAME_NOT_FOUND){
|
||||
printf("PANIC: ServerApp %s could not find the app_server port!\n",app->fSignature.String());
|
||||
break;
|
||||
}
|
||||
app->fMsgSender->SetPort(serverport);
|
||||
app->fMsgSender->SetPort(gAppServerPort);
|
||||
app->fMsgSender->StartMessage(AS_DELETE_APP);
|
||||
app->fMsgSender->Attach(&app->fMonitorThreadID, sizeof(thread_id));
|
||||
app->fMsgSender->Flush();
|
||||
|
Loading…
Reference in New Issue
Block a user