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:
@@ -73,6 +73,8 @@
|
|||||||
|
|
||||||
Desktop *desktop;
|
Desktop *desktop;
|
||||||
|
|
||||||
|
port_id gAppServerPort;
|
||||||
|
|
||||||
// TODO: Global ? Is it really needed ?
|
// TODO: Global ? Is it really needed ?
|
||||||
//! Used to access the app_server from new_decorator
|
//! Used to access the app_server from new_decorator
|
||||||
AppServer *app_server=NULL;
|
AppServer *app_server=NULL;
|
||||||
@@ -100,23 +102,25 @@ AppServer::AppServer(void) :
|
|||||||
fMessagePort = create_port(200, SERVER_PORT_NAME);
|
fMessagePort = create_port(200, SERVER_PORT_NAME);
|
||||||
if (fMessagePort == B_NO_MORE_PORTS)
|
if (fMessagePort == B_NO_MORE_PORTS)
|
||||||
debugger("app_server could not create message port");
|
debugger("app_server could not create message port");
|
||||||
|
|
||||||
|
gAppServerPort = fMessagePort;
|
||||||
|
|
||||||
// Create the input port. The input_server will send it's messages here.
|
// 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
|
// TODO: If we want multiple user support we would need an individual
|
||||||
// port for each user and do the following for each RootLayer.
|
// port for each user and do the following for each RootLayer.
|
||||||
fServerInputPort = create_port(200, SERVER_INPUT_PORT);
|
fServerInputPort = create_port(200, SERVER_INPUT_PORT);
|
||||||
if (fServerInputPort == B_NO_MORE_PORTS)
|
if (fServerInputPort == B_NO_MORE_PORTS)
|
||||||
debugger("app_server could not create input port");
|
debugger("app_server could not create input port");
|
||||||
|
|
||||||
fAppList= new BList();
|
fAppList = new BList();
|
||||||
fQuittingServer= false;
|
fQuittingServer = false;
|
||||||
make_decorator= NULL;
|
make_decorator = NULL;
|
||||||
|
|
||||||
// We need this in order for new_decorator to be able to instantiate new decorators
|
// 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.
|
// Create the font server and scan the proper directories.
|
||||||
fontserver=new FontServer;
|
fontserver = new FontServer;
|
||||||
fontserver->Lock();
|
fontserver->Lock();
|
||||||
|
|
||||||
// Used for testing purposes
|
// Used for testing purposes
|
||||||
@@ -168,37 +172,36 @@ AppServer::AppServer(void) :
|
|||||||
}
|
}
|
||||||
|
|
||||||
fontserver->Unlock();
|
fontserver->Unlock();
|
||||||
|
|
||||||
|
|
||||||
// Load the GUI colors here and set the global set to the values contained therein. If this
|
// 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
|
// is not possible, set colors to the defaults
|
||||||
if(!LoadGUIColors(&gui_colorset))
|
if (!LoadGUIColors(&gui_colorset))
|
||||||
gui_colorset.SetToDefaults();
|
gui_colorset.SetToDefaults();
|
||||||
|
|
||||||
InitDecorators();
|
InitDecorators();
|
||||||
|
|
||||||
// Set up the Desktop
|
// Set up the Desktop
|
||||||
desktop= new Desktop();
|
desktop = new Desktop();
|
||||||
desktop->Init();
|
desktop->Init();
|
||||||
|
|
||||||
// Create the bitmap allocator. Object declared in BitmapManager.cpp
|
// 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
|
// 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
|
// 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
|
// 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
|
// 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)
|
if (fPicassoThreadID >= 0)
|
||||||
resume_thread(fPicassoThreadID);
|
resume_thread(fPicassoThreadID);
|
||||||
|
|
||||||
fDecoratorName="Default";
|
fDecoratorName ="Default";
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
LaunchCursorThread();
|
LaunchCursorThread();
|
||||||
@@ -878,6 +881,10 @@ AppServer::FindApp(const char *sig)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// #pragma mark -
|
||||||
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\brief Creates a new decorator instance
|
\brief Creates a new decorator instance
|
||||||
\param rect Frame size
|
\param rect Frame size
|
||||||
@@ -919,7 +926,7 @@ int
|
|||||||
main(int argc, char** argv)
|
main(int argc, char** argv)
|
||||||
{
|
{
|
||||||
// There can be only one....
|
// 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;
|
return -1;
|
||||||
|
|
||||||
srand(real_time_clock_usecs());
|
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 <[email protected]>
|
||||||
|
*/
|
||||||
|
#ifndef _HAIKU_APP_SERVER_H_
|
||||||
|
#define _HAIKU_APP_SERVER_H_
|
||||||
|
|
||||||
#include <OS.h>
|
#include <OS.h>
|
||||||
#include <Locker.h>
|
#include <Locker.h>
|
||||||
@@ -26,10 +32,10 @@ class BitmapManager;
|
|||||||
application start and quit messages. It also starts the housekeeping threads
|
application start and quit messages. It also starts the housekeeping threads
|
||||||
and initializes most of the server's globals.
|
and initializes most of the server's globals.
|
||||||
*/
|
*/
|
||||||
#if TEST_MODE
|
|
||||||
class AppServer : public BApplication
|
|
||||||
#else
|
|
||||||
class AppServer
|
class AppServer
|
||||||
|
#if TEST_MODE
|
||||||
|
: public BApplication
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@@ -94,5 +100,6 @@ Decorator *new_decorator(BRect rect, const char *title, int32 wlook, int32 wfeel
|
|||||||
extern BitmapManager *bitmapmanager;
|
extern BitmapManager *bitmapmanager;
|
||||||
extern ColorSet gui_colorset;
|
extern ColorSet gui_colorset;
|
||||||
extern AppServer *app_server;
|
extern AppServer *app_server;
|
||||||
|
extern port_id gAppServerPort;
|
||||||
|
|
||||||
#endif
|
#endif /* _HAIKU_APP_SERVER_H_ */
|
||||||
|
|||||||
@@ -216,12 +216,7 @@ ServerApp::PingTarget(void)
|
|||||||
{
|
{
|
||||||
team_info tinfo;
|
team_info tinfo;
|
||||||
if (get_team_info(fClientTeamID,&tinfo) == B_BAD_TEAM_ID) {
|
if (get_team_info(fClientTeamID,&tinfo) == B_BAD_TEAM_ID) {
|
||||||
port_id serverport = find_port(SERVER_PORT_NAME);
|
fMsgSender->SetPort(gAppServerPort);
|
||||||
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->StartMessage(AS_DELETE_APP);
|
fMsgSender->StartMessage(AS_DELETE_APP);
|
||||||
fMsgSender->Attach(&fMonitorThreadID, sizeof(thread_id));
|
fMsgSender->Attach(&fMonitorThreadID, sizeof(thread_id));
|
||||||
fMsgSender->Flush();
|
fMsgSender->Flush();
|
||||||
@@ -308,12 +303,7 @@ ServerApp::MonitorApp(void *data)
|
|||||||
STRACE(("ServerApp::MonitorApp(): GetNextMessage returned %s\n", strerror(err)));
|
STRACE(("ServerApp::MonitorApp(): GetNextMessage returned %s\n", strerror(err)));
|
||||||
|
|
||||||
// ToDo: this should kill the app, but it doesn't work
|
// ToDo: this should kill the app, but it doesn't work
|
||||||
port_id serverport = find_port(SERVER_PORT_NAME);
|
app->fMsgSender->SetPort(gAppServerPort);
|
||||||
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->StartMessage(AS_DELETE_APP);
|
app->fMsgSender->StartMessage(AS_DELETE_APP);
|
||||||
app->fMsgSender->Attach(&app->fMonitorThreadID, sizeof(thread_id));
|
app->fMsgSender->Attach(&app->fMonitorThreadID, sizeof(thread_id));
|
||||||
app->fMsgSender->Flush();
|
app->fMsgSender->Flush();
|
||||||
@@ -393,12 +383,7 @@ ServerApp::MonitorApp(void *data)
|
|||||||
STRACE(("ServerApp %s: B_QUIT_REQUESTED\n",app->fSignature.String()));
|
STRACE(("ServerApp %s: B_QUIT_REQUESTED\n",app->fSignature.String()));
|
||||||
// Our BApplication sent us this message when it quit.
|
// Our BApplication sent us this message when it quit.
|
||||||
// We need to ask the app_server to delete ourself.
|
// We need to ask the app_server to delete ourself.
|
||||||
port_id serverport = find_port(SERVER_PORT_NAME);
|
app->fMsgSender->SetPort(gAppServerPort);
|
||||||
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->StartMessage(AS_DELETE_APP);
|
app->fMsgSender->StartMessage(AS_DELETE_APP);
|
||||||
app->fMsgSender->Attach(&app->fMonitorThreadID, sizeof(thread_id));
|
app->fMsgSender->Attach(&app->fMonitorThreadID, sizeof(thread_id));
|
||||||
app->fMsgSender->Flush();
|
app->fMsgSender->Flush();
|
||||||
|
|||||||
Reference in New Issue
Block a user