net_server: warning on delete of address of a reference.

* fixes #12244.
This commit is contained in:
Jérôme Duval
2015-11-22 11:51:56 +01:00
parent b8c67b27cc
commit d8e8078b3f
2 changed files with 14 additions and 14 deletions
+13 -13
View File
@@ -178,7 +178,7 @@ Services::~Services()
// stop all services // stop all services
while (!fNameMap.empty()) { while (!fNameMap.empty()) {
_StopService(*fNameMap.begin()->second); _StopService(fNameMap.begin()->second);
} }
} }
@@ -297,20 +297,20 @@ Services::_StartService(struct service& service)
status_t status_t
Services::_StopService(struct service& service) Services::_StopService(struct service* service)
{ {
printf("Stop service '%s'\n", service.name.c_str()); printf("Stop service '%s'\n", service->name.c_str());
// remove service from maps // remove service from maps
{ {
ServiceNameMap::iterator iterator = fNameMap.find(service.name); ServiceNameMap::iterator iterator = fNameMap.find(service->name);
if (iterator != fNameMap.end()) if (iterator != fNameMap.end())
fNameMap.erase(iterator); fNameMap.erase(iterator);
} }
if (!service.stand_alone) { if (!service->stand_alone) {
ConnectionList::const_iterator iterator = service.connections.begin(); ConnectionList::const_iterator iterator = service->connections.begin();
for (; iterator != service.connections.end(); iterator++) { for (; iterator != service->connections.end(); iterator++) {
const service_connection& connection = *iterator; const service_connection& connection = *iterator;
ServiceSocketMap::iterator socketIterator ServiceSocketMap::iterator socketIterator
@@ -324,12 +324,12 @@ Services::_StopService(struct service& service)
} }
// Shutdown the running server, if any // Shutdown the running server, if any
if (service.process != -1) { if (service->process != -1) {
printf(" Sending SIGTERM to process %" B_PRId32 "\n", service.process); printf(" Sending SIGTERM to process %" B_PRId32 "\n", service->process);
kill(-service.process, SIGTERM); kill(-service->process, SIGTERM);
} }
delete &service; delete service;
return B_OK; return B_OK;
} }
@@ -394,7 +394,7 @@ Services::_Update(const BMessage& services)
if (*service != *iterator->second) { if (*service != *iterator->second) {
printf("Restart service %s\n", service->name.c_str()); printf("Restart service %s\n", service->name.c_str());
_StopService(*iterator->second); _StopService(iterator->second);
_StartService(*service); _StartService(*service);
} else } else
iterator->second->update = fUpdate; iterator->second->update = fUpdate;
@@ -410,7 +410,7 @@ Services::_Update(const BMessage& services)
if (service->update != fUpdate) { if (service->update != fUpdate) {
// this service has to be removed // this service has to be removed
_StopService(*service); _StopService(service);
} }
} }
} }
+1 -1
View File
@@ -36,7 +36,7 @@ private:
void _NotifyListener(bool quit = false); void _NotifyListener(bool quit = false);
void _UpdateMinMaxSocket(int socket); void _UpdateMinMaxSocket(int socket);
status_t _StartService(struct service& service); status_t _StartService(struct service& service);
status_t _StopService(struct service& service); status_t _StopService(struct service* service);
status_t _ToService(const BMessage& message, status_t _ToService(const BMessage& message,
struct service*& service); struct service*& service);
void _Update(const BMessage& services); void _Update(const BMessage& services);