dbus cleanup question

Macartney, Geoff gmacartney at tycoint.com
Thu Feb 21 08:35:46 PST 2008


Hi 

I think I'm ok there - here's a précis of my test program:


int main(int argc, char *argv[])
{
        // ...snip... inits
        
        dbus_error_init(&error);
        conn = dbus_bus_get(DBUS_BUS_SYSTEM, &error);
        if (conn == NULL) {
                printf("Error: %s\n", error.message);
                return 1;
        }
        
        // don't exit on disconnect
        dbus_connection_set_exit_on_disconnect(conn, FALSE);
 
        // snip... set watch functions/handlers for messages & add matches

        while (! stop) {
            // ...snip... does a poll and calls dispatch to message
            // handlers, one of which will set the "stop" flag on receipt 
            // of a Disconnected message
        }

        printf("Terminating now\n");

        dbus_connection_unref(conn);
        dbus_shutdown();
}

Does that look all right?

Geoff


 
--------------------------------------------------------

Tyco Safety Products/CEM Systems Ltd.
Registered in Northern Ireland: NI 25728.  Registered Office: Unit 4 Ravenhill Business Park, Ravenhill Road, Belfast, BT6 8AW..
 
Please note that any views or opinions presented in this email are solely those of the author and do not necessarily represent those of the company. This email and any attachments are confidential and intended solely for the use of the individual or entity to whom they are addressed. If you have received this email in error please notify the sender immediately and delete any copies in your possession.
 
-----Original Message-----

From: havoc.pennington at gmail.com [mailto:havoc.pennington at gmail.com] On Behalf Of Havoc Pennington
Sent: 21 February 2008 16:21
To: Macartney, Geoff
Cc: dbus at lists.freedesktop.org
Subject: Re: dbus cleanup question

Hi,

On Thu, Feb 21, 2008 at 11:09 AM, Macartney, Geoff
<gmacartney at tycoint.com> wrote:
> I've tried things out with a small test program, just calling
>  dbus_bus_get once, and I still get the same result.

The key, though, is to be sure you unref() the connection from
dbus_bus_get() before you shutdown(). Also, be sure you try a newer
dbus (or scan ChangeLog for fixes related to this and apply any
related patches to your older version).

Havoc


More information about the dbus mailing list