From e90575224e1ec22701c0a7407234689087411936 Mon Sep 17 00:00:00 2001 From: Patrick Ohly Date: Tue, 16 Apr 2013 01:27:12 -0700 Subject: [PATCH] D-Bus: fix random session failures When the helper shuts down normally after the parent is done with it, there was a race between handling the signal and the loss of connection, leading to random "return 1" errors. This showed up in nightly testing in particular in the test-dbus.py testConfigure. The loss of connection at that point is not an error, so don't treat it as one and simply return 0. --- src/dbus/server/sync-helper.cpp | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/dbus/server/sync-helper.cpp b/src/dbus/server/sync-helper.cpp index 6c38b2a0..89303b80 100644 --- a/src/dbus/server/sync-helper.cpp +++ b/src/dbus/server/sync-helper.cpp @@ -163,16 +163,23 @@ int main(int argc, char **argv, char **envp) return 0; } if (forkexec->getState() != ForkExecChild::CONNECTED) { - // no point running any longer, parent is gone + // No point running any longer, parent is gone. + // + // This can occur during normal operations, so don't + // treat it as an error: + // - we send final method response + // - parent signals us and closes the connection + // - our event loop processes these two events such + // that we see the "not connected" one first SE_LOG_DEBUG(NULL, "parent has quit, terminating"); - return 1; + return 0; } g_main_context_iteration(NULL, true); } } catch ( const std::exception &ex ) { - SE_LOG_ERROR(NULL, "%s", ex.what()); + SE_LOG_ERROR(NULL, "helper quitting with exception: %s", ex.what()); } catch (...) { - SE_LOG_ERROR(NULL, "unknown error"); + SE_LOG_ERROR(NULL, "helper quitting: unknown error"); } return 1;