Results 1 to 5 of 5
Hello,
I was trying to trigger some task when DHCP does an DHCPACK on an IP. This I thought of achieving by using dbus signals.
I picked up the code ...
- 05-09-2009 #1Just Joined!
- Join Date
- Dec 2008
- Location
- Bangalore
- Posts
- 5
DBUS server misses out some signals.
Hello,
I was trying to trigger some task when DHCP does an DHCPACK on an IP. This I thought of achieving by using dbus signals.
I picked up the code from the following page --dbus dot freedesktop dor org/doc/dbus/libdbus-tutorial.html Read the "Receiving a Signal" section and modified it to my own requirements.
As for sending the signal I used the dbus-send command from DHCP server ( Inserting few statements in ISC DHCP's dhcpd.conf file by which on commit or on release the dbus-send command in triggered )
I am facing a problem, where some Signals do not reach the dbus server program. It happens once in 40-50 signals. But my application would not want to lose the Signals.
Part of my Code
dbus-server.c
Code:#include <dbus/dbus.h> #include <stdbool.h> #include <unistd.h> #include <stdio.h> #include <stdlib.h> #include<string.h> void receive() { DBusMessage* msg; DBusMessageIter args; DBusConnection* conn; DBusError err; int ret, ipcheck; char *sigvalue1, *message; dbus_bool_t sigvalue2; bool request_type; static int sequence_number = 0; dbus_error_init(&err); conn = dbus_bus_get(DBUS_BUS_SYSTEM, &err); ret = dbus_bus_request_name(conn, "com.example.app.Sink", DBUS_NAME_FLAG_REPLACE_EXISTING , &err); dbus_bus_add_match(conn, "type='signal',interface='com.example.app.Signal'", &err); dbus_connection_flush(conn); // All the checks were made to see if the connection is established. while (true) { dbus_connection_read_write(conn, 0); msg = dbus_connection_pop_message(conn); if (NULL == msg) { sleep(1); continue; } if (dbus_message_is_signal(msg, "com.example.app.Signal", "Test")) { fprintf(stdout,"\n#####################################################\n"); sequence_number++; fprintf(stdout,"\nSignal Sequence Number: %d\n",sequence_number); fflush(stdout); if (dbus_message_iter_init(msg, &args)) { dbus_message_iter_get_basic(&args,&sigvalue1); dbus_message_iter_next(&args); dbus_message_iter_get_basic(&args,&sigvalue2); fflush(stdout); if( sigvalue2 ) request_type=true; else request_type=false; if ( request_type ) { // DO SOMETHING dbus_message_unref(msg); continue; } else { // DO SOMETHING ELSE dbus_message_unref(msg); continue; } } } dbus_message_unref(msg); } // end of while loop }
A dbus-send command is sent using --
orCode:dbus-send --system --dest='com.example.app.Sink' --type=signal /com/example/app/Signal com.example.app.Signal.Test string:"192.168.47.100" boolean:true
I have an xml conf file in /etc/dbus-1/system.d/app.confCode:dbus-send --system --dest='com.example.app.Sink' --type=signal /com/example/app/Signal com.example.app.Signal.Test string:"192.168.47.100" boolean:false
I modified the dbus-server.c code to change the followingCode:<busconfig> <policy user="root"> <allow own="com.example.app.Source"/> <allow send_interface="com.example.app.Signal"/> <allow send_destination="com.example.app.Sink"/> </policy> <policy user="root"> <allow own="com.example.app.Sink"/> </policy> <policy context="default"> <deny own="com.example.app.Source"/> <deny send_destination="com.example.app.Sink"/> <deny send_interface="com.example.app.Signal"/> </policy> </busconfig>
dbus_connection_read_write(conn, 0); to
dbus_connection_read_write(conn, 1); and
dbus_connection_read_write(conn, 2);
But none had the required effect. Is there any glitch which is left which makes it lose the Signal ? I have picked most part of the code from the example provided on the tutorial, so I assume it should work. Can anyone provide any leads as to what is making the Signal to be lost.
Regards,
Abhijeet
- 05-09-2009 #2Linux Guru
- Join Date
- Apr 2009
- Location
- I can be found either 40 miles west of Chicago, or in a galaxy far, far away.
- Posts
- 8,974
I don't know enought about the behavior of dbus to know if it can lose messages or signals when in some sort of race condition. That would be my guess, and that it would be worse on busy systems. I don't know if you can verify that you lose more signals when the dbus is "clogged" with events and messages?
Sometimes, real fast is almost as good as real time.
Just remember, Semper Gumbi - always be flexible!
- 05-09-2009 #3Just Joined!
- Join Date
- Dec 2008
- Location
- Bangalore
- Posts
- 5
My machine where this dbus-server listens runs the DHCP server and the DNS server both. As per performance, the memory (physical ) and cache and the CPU are all OK.
- 05-09-2009 #4Linux Guru
- Join Date
- Apr 2009
- Location
- I can be found either 40 miles west of Chicago, or in a galaxy far, far away.
- Posts
- 8,974
Well, like I said, you need to profile the behavior of dbus to see if it loses more messages/signals when it is flooded with events to process. That's what I'd do - set up some additional test clients to generate and chart a randomized stream of events in ever-increasing volumes until I get some solid understanding of how it is handling heavy traffic and collisions.
Sometimes, real fast is almost as good as real time.
Just remember, Semper Gumbi - always be flexible!
- 05-09-2009 #5Linux Guru
- Join Date
- Apr 2009
- Location
- I can be found either 40 miles west of Chicago, or in a galaxy far, far away.
- Posts
- 8,974
I did some browsing thru the freedesktop.org Bugzilla bug list and found the following bug #'s which may be relevant. Note that some may have been "resolved", but it is possible that they still occur intermittently.
Bugs related to dbus signals fail to transmit: 13534, 17353, 16668
The web page is: https://bugs.freedesktop.org/Sometimes, real fast is almost as good as real time.
Just remember, Semper Gumbi - always be flexible!


Reply With Quote