Discussion:
connmanctl quitting before multiple return functions called
(too old to reply)
Craig McQueen
2015-10-14 06:49:35 UTC
Permalink
I've been looking into extending connmanctl's functionality with configuration for the net.connman.Clock API. I've been developing a command that can set clock properties, similar to the existing "config" command.

I've noticed that when multiple parameters are set, then the 'return' function is often not called. E.g.:

connmanctl config ethernet_4a4a5a6a3a0a_cable --ipv6 off --autoconnect yes --timeservers 0.pool.ntp.org

In this case, it sends 3 D-Bus commands, and config_return() should be called for each response. But it is likely to shutdown before calling config_return() all three times.

I see that dbus_method_reply() calls __connmanctl_quit(). That seems to be implicated in this. It seems the logic is to initiate shutdown after the response is received for the first D-Bus message sent.
--
Craig McQueen
Patrik Flykt
2015-10-14 07:57:17 UTC
Permalink
Hi,
Post by Craig McQueen
I've been looking into extending connmanctl's functionality with
configuration for the net.connman.Clock API. I've been developing a
command that can set clock properties, similar to the existing
"config" command.
I've noticed that when multiple parameters are set, then the 'return'
connmanctl config ethernet_4a4a5a6a3a0a_cable --ipv6 off
--autoconnect yes --timeservers 0.pool.ntp.org
In this case, it sends 3 D-Bus commands, and config_return() should be
called for each response. But it is likely to shutdown before calling
config_return() all three times.
I see that dbus_method_reply() calls __connmanctl_quit(). That seems
to be implicated in this. It seems the logic is to initiate shutdown
after the response is received for the first D-Bus message sent.
The logic has a bug here. It would be best if connmanctl exits after all
the method calls have completed. You are always free to send a patch for
this or implement it properly for Clock API commands, if you intend to
send patches for supporting that.

Cheers,

Patrik
Craig McQueen
2015-10-15 04:41:10 UTC
Permalink
Post by Patrik Flykt
Post by Craig McQueen
I've been looking into extending connmanctl's functionality with
configuration for the net.connman.Clock API. I've been developing a
command that can set clock properties, similar to the existing
"config" command.
I've noticed that when multiple parameters are set, then the 'return'
connmanctl config ethernet_4a4a5a6a3a0a_cable --ipv6 off
--autoconnect yes --timeservers 0.pool.ntp.org
In this case, it sends 3 D-Bus commands, and config_return() should be
called for each response. But it is likely to shutdown before calling
config_return() all three times.
I see that dbus_method_reply() calls __connmanctl_quit(). That seems
to be implicated in this. It seems the logic is to initiate shutdown
after the response is received for the first D-Bus message sent.
The logic has a bug here. It would be best if connmanctl exits after all
the method calls have completed. You are always free to send a patch for
this or implement it properly for Clock API commands, if you intend to
send patches for supporting that.
I've sent a patch of the connmanctl commands for Clock API. It works okay for my purposes, although it doesn't fix this issue. It works okay if getting only one property. This issue can be seen with the 'clock' command, reading multiple items. E.g.:

connmanctl clock time timeupdates timezone

which on my ARM embedded Linux based system, sometimes gets all three responses, but often only two.

I agree, it would be best if connmanctl exits after all the method calls have completed. I'd be happy to do a patch in principle, however I'm new to this D-Bus stuff and unfamiliar with the connman codebase, so at this point I'm not sure what is an architecturally elegant way to fix this. E.g., would it a counter which increments for each method call, and decrements when its response is received (and if so, does it need locks to be thread safe)? Or, is there some existing D-Bus code that already provides such functionality, e.g. returning true when there are no method calls waiting for a response?
--
Craig McQueen
Patrik Flykt
2015-10-29 08:12:16 UTC
Permalink
Hi,
Post by Craig McQueen
I agree, it would be best if connmanctl exits after all the method
calls have completed. I'd be happy to do a patch in principle, however
I'm new to this D-Bus stuff and unfamiliar with the connman codebase,
so at this point I'm not sure what is an architecturally elegant way
to fix this. E.g., would it a counter which increments for each method
call, and decrements when its response is received
Yes, that should work.
Post by Craig McQueen
(and if so, does it need locks to be thread safe)?
This is entirely single threaded using a main loop. No locking
structures needed.
Post by Craig McQueen
Or, is there some existing D-Bus code that already provides such
functionality, e.g. returning true when there are no method calls
waiting for a response?
Currently not. Looks like the 'config' command has the same problem
here. But that is a different "bug"...

Cheers,

Patrik

Loading...