diff options
author | Christian Mollekopf <chrigi_1@fastmail.fm> | 2017-10-31 14:04:03 +0100 |
---|---|---|
committer | Christian Mollekopf <chrigi_1@fastmail.fm> | 2017-10-31 14:04:03 +0100 |
commit | e1a3aebafca9a9447a393100db4fc45943551630 (patch) | |
tree | 39672297b576e967bd2448d6a795e5485f6995b7 /common | |
parent | 77b2173e73f16f33648226543788ea67096fb6d6 (diff) | |
download | sink-e1a3aebafca9a9447a393100db4fc45943551630.tar.gz sink-e1a3aebafca9a9447a393100db4fc45943551630.zip |
Ensure we get an appropriate exit code when a resource crashes.
Diffstat (limited to 'common')
-rw-r--r-- | common/domain/applicationdomaintype.h | 3 | ||||
-rw-r--r-- | common/resourceaccess.cpp | 4 | ||||
-rw-r--r-- | common/resourcecontrol.cpp | 7 |
3 files changed, 11 insertions, 3 deletions
diff --git a/common/domain/applicationdomaintype.h b/common/domain/applicationdomaintype.h index de2b5c9..dc4cbe1 100644 --- a/common/domain/applicationdomaintype.h +++ b/common/domain/applicationdomaintype.h | |||
@@ -102,7 +102,8 @@ enum SINK_EXPORT ErrorCode { | |||
102 | ConfigurationError, | 102 | ConfigurationError, |
103 | TransmissionError, | 103 | TransmissionError, |
104 | ConnectionLostError, | 104 | ConnectionLostError, |
105 | MissingCredentialsError | 105 | MissingCredentialsError, |
106 | ResourceCrashedError | ||
106 | }; | 107 | }; |
107 | 108 | ||
108 | enum SINK_EXPORT SuccessCode { | 109 | enum SINK_EXPORT SuccessCode { |
diff --git a/common/resourceaccess.cpp b/common/resourceaccess.cpp index a3478e6..8b70684 100644 --- a/common/resourceaccess.cpp +++ b/common/resourceaccess.cpp | |||
@@ -526,6 +526,10 @@ void ResourceAccess::connectionError(QLocalSocket::LocalSocketError error) | |||
526 | Sink::Notification n; | 526 | Sink::Notification n; |
527 | n.type = Sink::Notification::Status; | 527 | n.type = Sink::Notification::Status; |
528 | emit notification(n); | 528 | emit notification(n); |
529 | Sink::Notification crashNotification; | ||
530 | crashNotification.type = Sink::Notification::Error; | ||
531 | crashNotification.code = Sink::ApplicationDomain::ResourceCrashedError; | ||
532 | emit notification(crashNotification); | ||
529 | d->abortPendingOperations(); | 533 | d->abortPendingOperations(); |
530 | } else if (error == QLocalSocket::PeerClosedError) { | 534 | } else if (error == QLocalSocket::PeerClosedError) { |
531 | SinkLog() << "The resource closed the connection."; | 535 | SinkLog() << "The resource closed the connection."; |
diff --git a/common/resourcecontrol.cpp b/common/resourcecontrol.cpp index b6a4c0b..a69b7fa 100644 --- a/common/resourcecontrol.cpp +++ b/common/resourcecontrol.cpp | |||
@@ -101,10 +101,13 @@ KAsync::Job<void> ResourceControl::flush(Flush::FlushType type, const QByteArray | |||
101 | SinkTrace() << "Waiting for flush completion notification " << id; | 101 | SinkTrace() << "Waiting for flush completion notification " << id; |
102 | notifier->registerHandler([&future, id](const Notification ¬ification) { | 102 | notifier->registerHandler([&future, id](const Notification ¬ification) { |
103 | SinkTrace() << "Received notification: " << notification.type << notification.id; | 103 | SinkTrace() << "Received notification: " << notification.type << notification.id; |
104 | if (notification.id == id) { | 104 | if (notification.type == Notification::Error && notification.code == ApplicationDomain::ResourceCrashedError) { |
105 | SinkWarning() << "Error during flush"; | ||
106 | future.setError(-1, "Error during flush: " + notification.message); | ||
107 | } else if (notification.id == id) { | ||
105 | SinkTrace() << "FlushComplete"; | 108 | SinkTrace() << "FlushComplete"; |
106 | if (notification.code) { | 109 | if (notification.code) { |
107 | SinkWarning() << "Flush return an error"; | 110 | SinkWarning() << "Flush returned an error"; |
108 | future.setError(-1, "Flush returned an error: " + notification.message); | 111 | future.setError(-1, "Flush returned an error: " + notification.message); |
109 | } else { | 112 | } else { |
110 | future.setFinished(); | 113 | future.setFinished(); |