From e1a3aebafca9a9447a393100db4fc45943551630 Mon Sep 17 00:00:00 2001 From: Christian Mollekopf Date: Tue, 31 Oct 2017 14:04:03 +0100 Subject: Ensure we get an appropriate exit code when a resource crashes. --- common/domain/applicationdomaintype.h | 3 ++- common/resourceaccess.cpp | 4 ++++ common/resourcecontrol.cpp | 7 +++++-- 3 files changed, 11 insertions(+), 3 deletions(-) (limited to 'common') 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 { ConfigurationError, TransmissionError, ConnectionLostError, - MissingCredentialsError + MissingCredentialsError, + ResourceCrashedError }; 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) Sink::Notification n; n.type = Sink::Notification::Status; emit notification(n); + Sink::Notification crashNotification; + crashNotification.type = Sink::Notification::Error; + crashNotification.code = Sink::ApplicationDomain::ResourceCrashedError; + emit notification(crashNotification); d->abortPendingOperations(); } else if (error == QLocalSocket::PeerClosedError) { 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 ResourceControl::flush(Flush::FlushType type, const QByteArray SinkTrace() << "Waiting for flush completion notification " << id; notifier->registerHandler([&future, id](const Notification ¬ification) { SinkTrace() << "Received notification: " << notification.type << notification.id; - if (notification.id == id) { + if (notification.type == Notification::Error && notification.code == ApplicationDomain::ResourceCrashedError) { + SinkWarning() << "Error during flush"; + future.setError(-1, "Error during flush: " + notification.message); + } else if (notification.id == id) { SinkTrace() << "FlushComplete"; if (notification.code) { - SinkWarning() << "Flush return an error"; + SinkWarning() << "Flush returned an error"; future.setError(-1, "Flush returned an error: " + notification.message); } else { future.setFinished(); -- cgit v1.2.3