Actually there is little mix up of codes. We have g_main_loop running which i guess works for listening to dbus socket also. And to catch the signal dbus_bus_add_match & add_filter is used. So there is mix of dbus-glib bindings and some native code also. Does that might be causing the issue?<br>
<br>========== Sender Code ===========<br>DBusMessageIter iter, array_iter;<br>gchar array_sig[2];<br>gint i;<br>DBusError error;<br>array_sig[0] = DBUS_TYPE_STRING;<br>array_sig[1] = '\0';<br>
<br>gchar *app_interface = g_strconcat (APP_MGR_DBUS_INTERFACE,".", application, NULL);<br>gchar *app_objectpath = g_strconcat (APP_MGR_DBUS_OBJECT, "/", application, NULL);<br> <br>
while (value) {<br> params[no_of_params] = g_strdup(value);<br> no_of_params++;<br> value = va_arg (args, char*);<br> }<br><br> dbus_error_init (&error);<br>
<br> DBusConnection *bus_conn = dbus_bus_get (DBUS_BUS_SYSTEM, &error);<br><br> DBusMessage *msg = dbus_message_new_signal (app_objectpath, app_interface, APP_MGR_DBUS_SIGNAL_EXEC);<br>
if(msg == NULL)<br> {<br> g_critical(Not Enough Memory to create new dbus Message");<br> return -2;<br> }<br> <br> dbus_message_iter_init_append(msg, &iter);<br>
dbus_message_iter_append_basic(&iter, DBUS_TYPE_UINT32, &no_of_params);<br> dbus_message_iter_open_container(&iter, DBUS_TYPE_ARRAY, array_sig, &array_iter);<br> dbus_message_iter_append_basic (&array_iter, DBUS_TYPE_STRING, &application);<br>
<br> for(i=1; i<no_of_params; i++) {<br> dbus_message_iter_append_basic(&array_iter, DBUS_TYPE_STRING, &params[i]);<br> }<br> dbus_message_iter_close_container(&iter, &array_iter);<br>
<br> if (!dbus_connection_send(bus_conn, msg, 0)) <br> {<br> g_critical("Out Of Memory!");<br> return -3<br> }<br><br>======================= Receiver code ==============<br>
<br>DBusConnection *connection = dbus_bus_get (DBUS_BUS_SYSTEM, &error);<br> if(!connection)<br> {<br> g_critical("Failed to connect to D-Bus Daemon: !");<br> return -1;<br>
}<br>gchar match_str1[MAX_SIZE] = "type='signal',interface='";<br>g_strlcat(match_str1, APP_MGR_DBUS_INTERFACE, MAX_SIZE);<br>g_strlcat(match_str1, "'", MAX_SIZE);<br>dbus_bus_add_match (appclient_context.bus_conn, match_str1, NULL);<br>
<br> dbus_connection_add_filter (appclient_context.bus_conn, message_func, NULL, NULL);<br><br>---------------------------- message_func ---------<br><br>static DBusHandlerResult<br>message_func (DBusConnection *bus_conn, DBusMessage *msg, gpointer user_data)<br>
{<br> if (dbus_message_is_signal (msg, dbus_interface, APP_MGR_DBUS_SIGNAL_EXEC))<br> {<br> if(appclient_context.exec_callback!=NULL) {<br> DBusMessageIter iter, array_iter;<br>
guint no_of_param,i;<br> gchar *temp=NULL;<br> gchar **params_list=NULL;<br><br> dbus_message_iter_init(msg, &iter);<br> dbus_message_iter_get_basic(&iter, &no_of_param);<br>
dbus_message_iter_next(&iter);<br><br> if(((params_list = (gchar **)g_malloc0(((sizeof(gchar *))* no_of_param))) == NULL)) {<br> ("Out Of Memory!");<br>
return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;<br> }<br> if(no_of_param != 0)<br> {<br> dbus_message_iter_recurse(&iter, &array_iter);<br>
for(i=0; i<no_of_param;i++)<br> {<br><br> dbus_message_iter_get_basic(&array_iter, &temp);<br> if(((params_list[i] = (gchar *)g_malloc0(strlen(temp) + 1 )) == NULL)) {<br>
CLP_APPMGR_WARN("Out Of Memory!");<br> CLP_APPMGR_EXIT_FUNCTION();<br> return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;<br>
}<br><br> g_stpcpy (params_list[i], temp);<br> CLP_APPMGR_INFO_V("Restore ( Param %u : %s )",i, params_list[i] );<br>
dbus_message_iter_next(&array_iter);<br> }<br> }<br> (appclient_context.exec_callback)(no_of_param, params_list);<br>
<br> for(i=0;i<no_of_param;i++)<br> g_free(params_list[i]);<br> g_free(params_list);<br> }<br> }<br><br><br><br><br><br clear="all">
Cheers,<br>- Kaustubh <br><br>
<br><br><div class="gmail_quote">On Thu, Feb 26, 2009 at 2:21 PM, Thiago Macieira <span dir="ltr"><<a href="mailto:thiago@kde.org">thiago@kde.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Em Quinta-feira 26 Fevereiro 2009, ŕs 08:24:34, Kaustubh Atrawalkar escreveu:<br>
<div class="Ih2E3d">> I am using normal g_mail_loop for events integration in receiver side. And<br>
> the regular method of add_match & add_filter to poll on signals and read<br>
> them. I was too suspecting on the socket getting full but I added some<br>
> prints in - _dbus_connection_get_dispatch_status_unlocked . But can see<br>
> number "6" most of the time as number of incoming connections.<br>
> How can i avoid though if socket is getting full sometimes?<br>
<br>
</div>Sorry, I didn't understand one thing: are you using the dbus-glib binding or<br>
not?<br>
<br>
You mentioned integrating to g_main_loop, but you also said you were doing the<br>
integration work yourself. If that's the case, why are you integrating with<br>
glib yourself instead of using the binding?<br>
<br>
--<br>
<div class="Ih2E3d">Thiago Macieira - thiago (AT) <a href="http://macieira.info" target="_blank">macieira.info</a> - thiago (AT) <a href="http://kde.org" target="_blank">kde.org</a><br>
</div> Senior Product Manager - Nokia, Qt Software<br>
<div><div></div><div class="Wj3C7c"> PGP/GPG: 0x6EF45358; fingerprint:<br>
E067 918B B660 DBD1 105C 966C 33F5 F005 6EF4 5358<br>
</div></div><br>_______________________________________________<br>
dbus mailing list<br>
<a href="mailto:dbus@lists.freedesktop.org">dbus@lists.freedesktop.org</a><br>
<a href="http://lists.freedesktop.org/mailman/listinfo/dbus" target="_blank">http://lists.freedesktop.org/mailman/listinfo/dbus</a><br>
<br></blockquote></div><br>