* Now a service is quit when it is removed from the settings file.
* When deleting the Services handler, it will now also stop all running services, and close the command pipe (since it's only quit when the net_server quits, that wasn't much of a problem, though). git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@21566 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
7a3f6f9a07
commit
f6ad6dd6a6
@ -37,11 +37,12 @@ struct service_address {
|
||||
typedef vector<service_address> AddressList;
|
||||
|
||||
struct service {
|
||||
std::string name;
|
||||
std::string name;
|
||||
std::string launch;
|
||||
uid_t user;
|
||||
gid_t group;
|
||||
AddressList addresses;
|
||||
uid_t user;
|
||||
gid_t group;
|
||||
AddressList addresses;
|
||||
uint32 update;
|
||||
|
||||
~service();
|
||||
bool operator!=(const struct service& other) const;
|
||||
@ -187,6 +188,15 @@ Services::Services(const BMessage& services)
|
||||
Services::~Services()
|
||||
{
|
||||
wait_for_thread(fListener, NULL);
|
||||
|
||||
close(fReadPipe);
|
||||
close(fWritePipe);
|
||||
|
||||
// stop all services
|
||||
|
||||
while (!fNameMap.empty()) {
|
||||
_StopService(*fNameMap.begin()->second);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -260,6 +270,7 @@ Services::_StartService(struct service& service)
|
||||
// add service to maps and activate it
|
||||
|
||||
fNameMap[service.name] = &service;
|
||||
service.update = fUpdate;
|
||||
|
||||
iterator = service.addresses.begin();
|
||||
for (; iterator != service.addresses.end(); iterator++) {
|
||||
@ -456,7 +467,21 @@ Services::_Update(const BMessage& services)
|
||||
if (*service != *iterator->second) {
|
||||
_StopService(*iterator->second);
|
||||
_StartService(*service);
|
||||
}
|
||||
} else
|
||||
service->update = fUpdate;
|
||||
}
|
||||
}
|
||||
|
||||
// stop all services that are not part of the update message
|
||||
|
||||
ServiceNameMap::iterator iterator = fNameMap.begin();
|
||||
while (iterator != fNameMap.end()) {
|
||||
struct service* service = iterator->second;
|
||||
iterator++;
|
||||
|
||||
if (service->update != fUpdate) {
|
||||
// this service has to be removed
|
||||
_StopService(*service);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2006, Haiku, Inc. All Rights Reserved.
|
||||
* Copyright 2006-2007, Haiku, Inc. All Rights Reserved.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*
|
||||
* Authors:
|
||||
@ -48,7 +48,7 @@ class Services : public BHandler {
|
||||
BLocker fLock;
|
||||
ServiceNameMap fNameMap;
|
||||
ServiceSocketMap fSocketMap;
|
||||
int32 fUpdate;
|
||||
uint32 fUpdate;
|
||||
int fReadPipe;
|
||||
int fWritePipe;
|
||||
int fMinSocket;
|
||||
|
Loading…
Reference in New Issue
Block a user