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; BList* fCommonFilters;
bool fTerminating; bool fTerminating;
bool fRunCalled; bool fRunCalled;
bool fOwnsPort;
uint32 _reserved[11]; uint32 _reserved[11];
}; };
+2
View File
@@ -267,6 +267,8 @@ BApplication::BApplication(const char* signature, const char* looperName,
looperName != NULL ? looperName : kDefaultLooperName) looperName != NULL ? looperName : kDefaultLooperName)
{ {
_InitData(signature, initGUI, _error); _InitData(signature, initGUI, _error);
if (port < 0)
fOwnsPort = false;
} }
+6 -3
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. * Distributed under the terms of the MIT License.
* *
* Authors: * Authors:
@@ -130,7 +130,7 @@ BLooper::~BLooper()
} }
// Close the message port and read and reply to the remaining messages. // Close the message port and read and reply to the remaining messages.
if (fMsgPort >= 0) if (fMsgPort >= 0 && fOwnsPort)
close_port(fMsgPort); close_port(fMsgPort);
// Clear the queue so our call to IsMessageWaiting() below doesn't give // Clear the queue so our call to IsMessageWaiting() below doesn't give
@@ -143,13 +143,15 @@ BLooper::~BLooper()
// msg will automagically post generic reply // msg will automagically post generic reply
} }
if (!fOwnsPort) {
do { do {
delete ReadMessageFromPort(0); delete ReadMessageFromPort(0);
// msg will automagically post generic reply // msg will automagically post generic reply
} while (IsMessageWaiting()); } while (IsMessageWaiting());
fDirectTarget->Release();
delete_port(fMsgPort); delete_port(fMsgPort);
}
fDirectTarget->Release();
// Clean up our filters // Clean up our filters
SetCommonFilterList(NULL); SetCommonFilterList(NULL);
@@ -945,6 +947,7 @@ BLooper::_InitData(const char* name, int32 priority, port_id port,
fPreferred = NULL; fPreferred = NULL;
fThread = B_ERROR; fThread = B_ERROR;
fTerminating = false; fTerminating = false;
fOwnsPort = true;
fMsgPort = -1; fMsgPort = -1;
fAtomicCount = 0; fAtomicCount = 0;