diff options
author | Christian Mollekopf <chrigi_1@fastmail.fm> | 2016-05-22 13:12:02 +0200 |
---|---|---|
committer | Christian Mollekopf <chrigi_1@fastmail.fm> | 2016-05-22 13:12:02 +0200 |
commit | ecf5bd3c4fd8557b06c6849b317d8d3ccaca528f (patch) | |
tree | 6d7d038b6d705356040e8b1f331c075f90b7c690 /common | |
parent | 6864e4accaafa4fa90332719bff5a85a0e92b242 (diff) | |
download | sink-ecf5bd3c4fd8557b06c6849b317d8d3ccaca528f.tar.gz sink-ecf5bd3c4fd8557b06c6849b317d8d3ccaca528f.zip |
A better crashhandler that notifies the client of the crash.
Diffstat (limited to 'common')
-rw-r--r-- | common/listener.cpp | 17 | ||||
-rw-r--r-- | common/listener.h | 1 | ||||
-rw-r--r-- | common/resourceaccess.cpp | 6 |
3 files changed, 23 insertions, 1 deletions
diff --git a/common/listener.cpp b/common/listener.cpp index 28748e5..de20b2c 100644 --- a/common/listener.cpp +++ b/common/listener.cpp | |||
@@ -87,6 +87,23 @@ Listener::~Listener() | |||
87 | { | 87 | { |
88 | } | 88 | } |
89 | 89 | ||
90 | void Listener::emergencyAbortAllConnections() | ||
91 | { | ||
92 | for (Client &client : m_connections) { | ||
93 | if (client.socket) { | ||
94 | Warning() << "Sending panic"; | ||
95 | client.socket->write("PANIC"); | ||
96 | client.socket->waitForBytesWritten(); | ||
97 | disconnect(client.socket, 0, this, 0); | ||
98 | client.socket->abort(); | ||
99 | delete client.socket; | ||
100 | client.socket = 0; | ||
101 | } | ||
102 | } | ||
103 | |||
104 | m_connections.clear(); | ||
105 | } | ||
106 | |||
90 | void Listener::closeAllConnections() | 107 | void Listener::closeAllConnections() |
91 | { | 108 | { |
92 | for (Client &client : m_connections) { | 109 | for (Client &client : m_connections) { |
diff --git a/common/listener.h b/common/listener.h index cd1a7f6..5e376c7 100644 --- a/common/listener.h +++ b/common/listener.h | |||
@@ -64,6 +64,7 @@ signals: | |||
64 | 64 | ||
65 | public slots: | 65 | public slots: |
66 | void closeAllConnections(); | 66 | void closeAllConnections(); |
67 | void emergencyAbortAllConnections(); | ||
67 | 68 | ||
68 | private slots: | 69 | private slots: |
69 | void acceptConnection(); | 70 | void acceptConnection(); |
diff --git a/common/resourceaccess.cpp b/common/resourceaccess.cpp index 458694f..991c930 100644 --- a/common/resourceaccess.cpp +++ b/common/resourceaccess.cpp | |||
@@ -474,7 +474,11 @@ void ResourceAccess::disconnected() | |||
474 | 474 | ||
475 | void ResourceAccess::connectionError(QLocalSocket::LocalSocketError error) | 475 | void ResourceAccess::connectionError(QLocalSocket::LocalSocketError error) |
476 | { | 476 | { |
477 | if (error == QLocalSocket::PeerClosedError) { | 477 | const bool resourceCrashed = d->partialMessageBuffer.contains("PANIC"); |
478 | if (resourceCrashed) { | ||
479 | ErrorMsg() << "The resource crashed!"; | ||
480 | d->abortPendingOperations(); | ||
481 | } else if (error == QLocalSocket::PeerClosedError) { | ||
478 | Log() << "The resource closed the connection."; | 482 | Log() << "The resource closed the connection."; |
479 | d->abortPendingOperations(); | 483 | d->abortPendingOperations(); |
480 | } else { | 484 | } else { |