diff options
author | Gyuhwan Park★ <unstabler@unstabler.pl> | 2023-02-04 12:43:43 +0300 |
---|---|---|
committer | Gyuhwan Park★ <unstabler@unstabler.pl> | 2023-02-04 12:43:43 +0300 |
commit | 877b1cca50a2eb9670e901525ad6d83803adfd68 (patch) | |
tree | 3d1aea7e107d69515ffc33cf932f6aac44595dc5 /IPCConnection.cpp | |
parent | 18701d80d5590748d6a27561e7d90e0e7a7a1534 (diff) |
fix(IPCConnection): add good bit field, resolves #2
Diffstat (limited to 'IPCConnection.cpp')
-rw-r--r-- | IPCConnection.cpp | 16 |
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; } |