Review Request 125483: [KDBusService] Don't exit after calling Activate if user specified NoExitOnFailure flag

Martin Klapetek martin.klapetek at gmail.com
Wed Oct 7 17:14:03 UTC 2015



> On Oct. 2, 2015, 10:35 p.m., David Faure wrote:
> > Sending Activate to a running Unique process is not a failure, so NoExitOnFailure should not affect it.
> > 
> > If you need a "no exit, ever" flag, then I would recommend adding a separate flag for that. I'm not sure I understand the use case though.
> 
> Martin Klapetek wrote:
>     In terms of the this code, the "failure" is "!d->registered" (see line 147 or 153 with this patch), so it is a failure to register the service (this is also supported by the docs saying "Indicates that the application should not exit if it failed to register with D-Bus."). So even if it sends Activate, it still failed to register the service and therefore the NoExitOnFailure should apply. No?
> 
> David Faure wrote:
>     While that might be one way to literally interpret the docs, it's definitely not what I had in mind when I wrote them.
>     See "Already running so it's ok!", the fact that there is no "errorMessage" set in this case, and the fact that the current use of NoExitOnFailure happens right before qCritical() + exit.
>     
>     Process already running is not an error or a failure, it's a perfectly normal situation.
>     
>     What I can't really remember is the use case for NoExitOnFailure; I think it was "being able to start the app even if there's no DBus running at all", at the expense of losing the Unique behavior of course.
>     
>     Back to your use case, I wonder why "pass data" can't be done with the CommandLine method. Or are we talking about different data than the command line? Which other data could there be, in an application we just started ?
> 
> Martin Klapetek wrote:
>     > Process already running is not an error or a failure, it's a perfectly normal situation.
>     
>     It isn't, the "failure" in this context of KDBusService as I understand it from the docs and the code is just the failure to register the unique dbus service, which I thought the NoExitOnFailure is meant for.
>     
>     I mean it would be nice if the user had a choice to not forcefully exit when it cannot get the unique dbus service.
>     
>     Anyways, the main reason for this patch comes from kwalletd, which has this code:
>     
>         KDBusService dbusUniqueInstance(KDBusService::Unique | KDBusService::NoExitOnFailure);
>         // NOTE: the command should be parsed only after KDBusService instantiation
>         QCommandLineParser cmdParser;
>         aboutdata.setupCommandLine(&cmdParser);
>         cmdParser.process(app);
>     
>     
>         if (!dbusUniqueInstance.isRegistered()) {
>             qDebug() << "kwalletd is already running!";
>             return 1;
>         }
>         
>     Now the code exits at the first line and never reaches the if below, which I originally wanted to extend to instead check for a locked wallet and unlock it with PAM (in case this kwalletd was executed from PAM) and only then actually exit.

The other usecase for this patch can be seen in the code excerpt above - returning custom values in main(). Eg. kwalletd would return 1 in case it couldn't register on dbus, but KDBusService exits with 0 instead.


- Martin


-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://git.reviewboard.kde.org/r/125483/#review86249
-----------------------------------------------------------


On Oct. 2, 2015, 7:52 p.m., Martin Klapetek wrote:
> 
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> https://git.reviewboard.kde.org/r/125483/
> -----------------------------------------------------------
> 
> (Updated Oct. 2, 2015, 7:52 p.m.)
> 
> 
> Review request for KDE Frameworks and David Faure.
> 
> 
> Repository: kdbusaddons
> 
> 
> Description
> -------
> 
> If KDBusService fails to register Unique service because other instance is already running and if the user specified NoExitOnFailure, don't exit after calling "Activate" on the other instance.
> 
> 
> Diffs
> -----
> 
>   src/kdbusservice.cpp ea7727d 
> 
> Diff: https://git.reviewboard.kde.org/r/125483/diff/
> 
> 
> Testing
> -------
> 
> App no longer exits and can do some other tasks like calling a different dbus method to eg. pass data and then exit on its own.
> 
> 
> Thanks,
> 
> Martin Klapetek
> 
>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kde.org/pipermail/kde-frameworks-devel/attachments/20151007/bba6166b/attachment.html>


More information about the Kde-frameworks-devel mailing list