Needed help in Asynchronous DBus method call using low level APIs
Thiago Macieira
thiago at kde.org
Mon Aug 29 07:53:23 PDT 2011
On Monday, 29 de August de 2011 20:02:54 kuladeep chowdary wrote:
> Hi All,
>
> I am new to DBus IPC. I am trying to call a method in server, from client
> and getting reply asynchronously, using *dbus_pending_call_set_notify( )
> *API.. But i am failing to get it done. i am testing even for pending call
> is NULL or not.. but still i am unable to get it.. i suspect before server
> sends reply, client process is exiting. But i think internally there will
> be thread running to get the reply message asynchronously, but its not
> happening. I am bit confused.. :( I am attaching the code(both server.c and
> client.c). Please help to sort out this issue. some sample code will be
> very much help full..
Hello
Let's start by addressing the part where you say "there will be thread
running". There's no call to pthread_create in your code, nor anything with
"thread" anywhere. If you didn't start a thread, there is no other thread
running.
You're making a wrong assumption that D-Bus has threads in the background. It
doesn't.
In your client.c code, on line 66 you send the call. If the sending succeeds,
you'll set the notify function on line 73. So far so good.
The next step is line 84, where you unref the pending connection. That means
you no longer care about receiving the reply. After that, you exit the
program.
If you wish to receive the reply, you must wait for the reply to arrive before
you unref the "pending" object.
--
Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
Software Architect - Intel Open Source Technology Center
PGP/GPG: 0x6EF45358; fingerprint:
E067 918B B660 DBD1 105C 966C 33F5 F005 6EF4 5358
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 190 bytes
Desc: This is a digitally signed message part.
URL: <http://lists.freedesktop.org/archives/dbus/attachments/20110829/efd243e7/attachment.pgp>
More information about the dbus
mailing list