The dbus_message_has_interface method return false, my service can't start, please help!

刘铁罡 liutiegang at navchina.com
Mon Feb 27 07:01:48 UTC 2017


Dear all,

I am investigating on DBUS porting on QNX. DBus-daemon can be run now.
And then I download the dbus-example.c on http://www.matthew.ath.cx/misc/dbus. Compile and run dbus_example_g.

My running steps are:

1.      #DBUS_VERSION=1 dbus-daemon --print-address --config-file=/home/test/dbus/share/dbus-1/session.conf --nofork &

2.      #export DBUS_SESSION_BUS_ADDRESS=unix:path=/home/test/dbus/temp/dbus-WmaQFMvqxD,guid=7a9055f9b14393e3276108b958b3b792

3.      #./dbus_example_g receive
In daemon process, I got the null connection, I debug into the source code, find the following clue, please see the red lines.
dbus_message_has_interface (DBusMessage   *message,
                            const char    *iface)
{
  const char *msg_interface;
  msg_interface = dbus_message_get_interface (message); // msg_interface is Org.freedesktop.dbus.local, but iface is org.freedesktop.dbus.peer

  if (msg_interface == NULL)
    {
      if (iface == NULL)
      {
        return TRUE;
      }
      else
      {
        return FALSE;
      }
    }

  if (iface == NULL)
  {
    return FALSE;
  }

  if (strcmp (msg_interface, iface) == 0) //org.freedesktop.dbus.local!=org.freedesktop.dbus.peer
    return TRUE;

  return FALSE;

}

So

static DBusHandlerResult
_dbus_connection_peer_filter_unlocked_no_update (DBusConnection *connection,
                                                 DBusMessage    *message)
{
  ……
  if (!dbus_message_has_interface (message, DBUS_INTERFACE_PEER))
    {
      return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; //quit, so the following Ping and GetMachineId can’t be run!
}
  ……
  if (dbus_message_is_method_call (message,
                                   DBUS_INTERFACE_PEER,
                                   "Ping"))
{
……
    }
  else if (dbus_message_is_method_call (message,
                                        DBUS_INTERFACE_PEER,
                                        "GetMachineId"))
{
……
}

Any help will be appreciated.

Thanks!
Tiegang

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/dbus/attachments/20170227/ecefab97/attachment-0001.html>


More information about the dbus mailing list