Dbus method call sent but no reply got

Fei Zheng Fei.Zheng at csr.com
Sun Sep 15 22:59:27 PDT 2013


Hi,

I need your help to resolve a problem about making method call but no reply got.

In Dbus_send.c, method call is the sent to remote and block to wait the reply.

1.        dbus_bus_get()

2.       dbus_message_new_method_call()

3.       dbus_connection_send_with_reply_and_block()

in dbus_recv.c,  message_handler () is registered to handle the method call, then enter the main loop to dispatch the message.

1.       dbus_bus_get()

2.       dbus_bus_request_name()

3.       dbus_connection_register_object_path()

4.       dbus_connection_read_write_dispatch()

In message_handler, if signal_handler() is called to send the reply in the this function, In Dbus_send.c the caller could get the reply correctly. But if the reply is sent asynchronously in a signal handler,  the reply could not be got by the caller.

static DBusHandlerResult  message_handler (DBusConnection *connection, DBusMessage *message, void *user_data)
 {
                dmsg  = message;
                dconn = connection;

#if 1
                //reply cannot be got by sender when reply is sent in a signal handler.

                printf("Create signal\n");
                incb = 0;
                signal(SIGALRM, sigHandler);
                printf("Start timer \n");
                alarm(1);
                printf("Increase the reference\n");
                dbus_connection_ref(connection);
                dbus_message_ref(message);

#else
// it is ok to send the reply here.
                signal_handler();
#endif

                return DBUS_HANDLER_RESULT_HANDLED;
}

The two file is attached, could you help check what's wrong with it? Thanks.

Best regards
Fei Zheng



Member of the CSR plc group of companies. CSR plc registered in England and Wales, registered number 4187346, registered office Churchill House, Cambridge Business Park, Cowley Road, Cambridge, CB4 0WZ, United Kingdom
More information can be found at www.csr.com. Follow CSR on Twitter at http://twitter.com/CSR_PLC and read our blog at www.csr.com/blog
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/dbus/attachments/20130916/83757fdf/attachment.html>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: dbus_recv.c
URL: <http://lists.freedesktop.org/archives/dbus/attachments/20130916/83757fdf/attachment.c>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: dbus_send.c
URL: <http://lists.freedesktop.org/archives/dbus/attachments/20130916/83757fdf/attachment-0001.c>


More information about the dbus mailing list