* 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
@ -42,6 +42,7 @@ struct service {
|
|||||||
uid_t user;
|
uid_t user;
|
||||||
gid_t group;
|
gid_t group;
|
||||||
AddressList addresses;
|
AddressList addresses;
|
||||||
|
uint32 update;
|
||||||
|
|
||||||
~service();
|
~service();
|
||||||
bool operator!=(const struct service& other) const;
|
bool operator!=(const struct service& other) const;
|
||||||
@ -187,6 +188,15 @@ Services::Services(const BMessage& services)
|
|||||||
Services::~Services()
|
Services::~Services()
|
||||||
{
|
{
|
||||||
wait_for_thread(fListener, NULL);
|
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
|
// add service to maps and activate it
|
||||||
|
|
||||||
fNameMap[service.name] = &service;
|
fNameMap[service.name] = &service;
|
||||||
|
service.update = fUpdate;
|
||||||
|
|
||||||
iterator = service.addresses.begin();
|
iterator = service.addresses.begin();
|
||||||
for (; iterator != service.addresses.end(); iterator++) {
|
for (; iterator != service.addresses.end(); iterator++) {
|
||||||
@ -456,8 +467,22 @@ Services::_Update(const BMessage& services)
|
|||||||
if (*service != *iterator->second) {
|
if (*service != *iterator->second) {
|
||||||
_StopService(*iterator->second);
|
_StopService(*iterator->second);
|
||||||
_StartService(*service);
|
_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.
|
* Distributed under the terms of the MIT License.
|
||||||
*
|
*
|
||||||
* Authors:
|
* Authors:
|
||||||
@ -48,7 +48,7 @@ class Services : public BHandler {
|
|||||||
BLocker fLock;
|
BLocker fLock;
|
||||||
ServiceNameMap fNameMap;
|
ServiceNameMap fNameMap;
|
||||||
ServiceSocketMap fSocketMap;
|
ServiceSocketMap fSocketMap;
|
||||||
int32 fUpdate;
|
uint32 fUpdate;
|
||||||
int fReadPipe;
|
int fReadPipe;
|
||||||
int fWritePipe;
|
int fWritePipe;
|
||||||
int fMinSocket;
|
int fMinSocket;
|
||||||
|
Loading…
Reference in New Issue
Block a user