BLooper: don't delete a launch_daemon port.

* Unless the service is really to be quit, the port should stay around;
  but that decision is to be made by the launch_daemon, not the service
  itself.
This commit is contained in:
Axel Dörfler
2015-07-22 20:40:52 +02:00
parent 4bf862e368
commit 798ad3db30
3 changed files with 13 additions and 7 deletions
+1
View File
@@ -172,6 +172,7 @@ private:
BList* fCommonFilters;
bool fTerminating;
bool fRunCalled;
bool fOwnsPort;
uint32 _reserved[11];
};
+2
View File
@@ -267,6 +267,8 @@ BApplication::BApplication(const char* signature, const char* looperName,
looperName != NULL ? looperName : kDefaultLooperName)
{
_InitData(signature, initGUI, _error);
if (port < 0)
fOwnsPort = false;
}
+10 -7
View File
@@ -1,5 +1,5 @@
/*
* Copyright 2001-2013 Haiku, Inc. All rights reserved
* Copyright 2001-2015 Haiku, Inc. All rights reserved
* Distributed under the terms of the MIT License.
*
* Authors:
@@ -130,7 +130,7 @@ BLooper::~BLooper()
}
// Close the message port and read and reply to the remaining messages.
if (fMsgPort >= 0)
if (fMsgPort >= 0 && fOwnsPort)
close_port(fMsgPort);
// Clear the queue so our call to IsMessageWaiting() below doesn't give
@@ -143,13 +143,15 @@ BLooper::~BLooper()
// msg will automagically post generic reply
}
do {
delete ReadMessageFromPort(0);
// msg will automagically post generic reply
} while (IsMessageWaiting());
if (!fOwnsPort) {
do {
delete ReadMessageFromPort(0);
// msg will automagically post generic reply
} while (IsMessageWaiting());
delete_port(fMsgPort);
}
fDirectTarget->Release();
delete_port(fMsgPort);
// Clean up our filters
SetCommonFilterList(NULL);
@@ -945,6 +947,7 @@ BLooper::_InitData(const char* name, int32 priority, port_id port,
fPreferred = NULL;
fThread = B_ERROR;
fTerminating = false;
fOwnsPort = true;
fMsgPort = -1;
fAtomicCount = 0;