Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/neutrinolabs/ulalaca-xrdp.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGyuhwan Park★ <unstabler@unstabler.pl>2023-02-04 12:43:43 +0300
committerGyuhwan Park★ <unstabler@unstabler.pl>2023-02-04 12:43:43 +0300
commit877b1cca50a2eb9670e901525ad6d83803adfd68 (patch)
tree3d1aea7e107d69515ffc33cf932f6aac44595dc5 /IPCConnection.cpp
parent18701d80d5590748d6a27561e7d90e0e7a7a1534 (diff)
fix(IPCConnection): add good bit field, resolves #2
Diffstat (limited to 'IPCConnection.cpp')
-rw-r--r--IPCConnection.cpp16
1 files changed, 15 insertions, 1 deletions
diff --git a/IPCConnection.cpp b/IPCConnection.cpp
index c23fd36..6b49da4 100644
--- a/IPCConnection.cpp
+++ b/IPCConnection.cpp
@@ -23,7 +23,8 @@ IPCConnection::IPCConnection(std::string socketPath):
_isWorkerTerminated(false),
_messageId(0),
- _ackId(0)
+ _ackId(0),
+ _isGood(true)
{
}
@@ -54,6 +55,10 @@ void IPCConnection::disconnect() {
_socket.close();
}
+bool IPCConnection::isGood() const {
+ return _isGood;
+}
+
std::unique_ptr<ULIPCHeader, IPCConnection::MallocFreeDeleter> IPCConnection::nextHeader() {
return std::move(read<ULIPCHeader>(sizeof(ULIPCHeader)));
}
@@ -87,6 +92,8 @@ void IPCConnection::workerLoop() {
0
};
+ _isGood = true;
+
while (!_isWorkerTerminated) {
if (poll(&pollFd, 1, -1) < 0) {
throw SystemCallException(errno, "poll");
@@ -138,6 +145,10 @@ void IPCConnection::workerLoop() {
}
}
+ if (_isGood && retval <= 0) {
+ break;
+ }
+
readPos += retval;
if (readPos >= contentLength) {
@@ -154,6 +165,7 @@ void IPCConnection::workerLoop() {
if (pollFd.revents & POLLHUP) {
LOG(LOG_LEVEL_WARNING, "POLLHUP bit set");
+ _isGood = false;
if (_readTasks.empty()) {
LOG(LOG_LEVEL_WARNING, "POLLHUP bit set; closing connection");
@@ -166,4 +178,6 @@ void IPCConnection::workerLoop() {
break;
}
}
+
+ _isGood = false;
}