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.
This commit is contained in:
Patrick Ohly 2013-04-16 01:27:12 -07:00
parent 8db33a4ba5
commit e90575224e

View file

@ -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;