Re: Hang in libnm_glib_init
- From: Dan Williams <dcbw redhat com>
- To: Richard Laager <rlaager wiktel com>
- Cc: networkmanager-list gnome org
- Subject: Re: Hang in libnm_glib_init
- Date: Thu, 26 Oct 2006 13:36:43 -0400
On Thu, 2006-10-26 at 12:08 -0500, Richard Laager wrote:
> On Thu, 2006-10-26 at 10:43 -0400, Dan Williams wrote:
> > Admittedly, libnm_glib is pretty bad, but was developed as a hack for eg
> > firefox to not have to hook up to DBus directly.
>
> So perhaps we should be hooking into NetworkManager differently? We have
> DBus support already, so that shouldn't be a problem for us like it
> might be for FireFox.
Right. If you've already got DBus support, it's not hard to add the
bits for NM, and that would probably be the way to go. libnm_glib is
probably not suitable for you right now.
You'll at a minimum, need to:
1) On startup, look for the NetworkManager service.
1a) If it does not exist, behavior is up to you whether you want to
assume that a valid network connection is present, or whether you have
some other mechanism to run through the routing table and see if there
are valid entries for a gateway, or check all network adapters for valid
IP addresses and whether they are IFF_UP or whatever
1b) If the NM service is running, then query NM state using the 'state'
method of the /org/freedesktop/NetworkManager object on the
'org.freedesktop.NetworkManager' interface. The reply to state will be
a single DBUS_TYPE_UINT32, with values corresponding to the NMState enum
in /usr/include/NetworkManager/NetworkManager.h, or:
typedef enum NMState
{
NM_STATE_UNKNOWN = 0,
NM_STATE_ASLEEP,
NM_STATE_CONNECTING,
NM_STATE_CONNECTED,
NM_STATE_DISCONNECTED
} NMState;
If NM is running, you'll also want to add a signal match for the
"StateChange" signal:
#define NM_DBUS_SIGNAL_STATE_CHANGE "StateChange"
The parameters passed iwth that signal are the same as the "state"
method call, a single DBUS_TYPE_UINT32.
2) Install a handler for the D-Bus signal NameOwnerChanged.
2a) If you get a NOC and NM has gone away, do whatever you feel is
appropriate. NM has probably taken down your network connection if it
exited cleanly.
2b) If you get a NOC and NM has appeared, query NM's state like you did
when you started up, if NM appeared.
The code in libnm_glib should be a pretty good guide of what needs to
happen, if you're using straight DBus and the C bindings. Feel free to
mail the list with more questions!
Dan
> > In any case, the only
> > g_usleep() in libnm_glib is waiting for dbus handler thread to start.
>
> DBus threading... I was afraid of that. There was recently a RedHat
> bugzilla bug on a similar issue in Gaim. I don't have the number
> off-hand, but maybe Warren does. It was something with deadlocks because
> the GTK+ file chooser would init the vfs library, which used threads,
> and DBus used threads, and the initializations didn't play well
> together. IIRC, eventually this was fixed in DBus, so maybe this isn't a
> problem with newer versions of DBus?
>
> > Instead of doing a 'bt', can you do a 't a a bt' (thread apply all
> > backtrace) to get a backtrace that includes _all_ threads?
>
> (gdb) r
> Starting program: /home/rlaager/bin/gaim-HEAD
> [Thread debugging using libthread_db enabled]
> [New Thread -1209166144 (LWP 27296)]
> [New Thread -1214899280 (LWP 27300)]
>
> Program received signal SIGINT, Interrupt.
> [Switching to Thread -1209166144 (LWP 27296)]
> 0xffffe410 in __kernel_vsyscall ()
> (gdb) thread a a bt
>
> Thread 2 (Thread -1214899280 (LWP 27300)):
> #0 0xffffe410 in __kernel_vsyscall ()
> #1 0x47a5c2ae in __lll_mutex_lock_wait ()
> from /lib/tls/i686/cmov/libpthread.so.0
> #2 0x47a58fbb in _L_mutex_lock_33 ()
> from /lib/tls/i686/cmov/libpthread.so.0
> #3 0xb79612b8 in ?? ()
> #4 0x4b2bdb6c in dbus_g_object_path_get_g_type ()
> from /usr/lib/libdbus-glib-1.so.2
> #5 0x4b2bdb34 in dbus_g_object_path_get_g_type ()
> from /usr/lib/libdbus-glib-1.so.2
> #6 0x47b793d7 in dbus_timeout_get_enabled ()
> from /usr/lib/libdbus-1.so.2
> #7 0x47b7bbd7 in dbus_watch_handle () from /usr/lib/libdbus-1.so.2
> #8 0x47b66aae in dbus_connection_allocate_data_slot ()
> from /usr/lib/libdbus-1.so.2
> #9 0x47b6108f in dbus_address_unescape_value ()
> from /usr/lib/libdbus-1.so.2
> #10 0x47b61514 in dbus_bus_register () from /usr/lib/libdbus-1.so.2
> #11 0xb7ede4f9 in libnm_glib_dbus_init (user_data=0x818aca8,
> context=0x8185e00)
> at libnm_glib.c:298
> #12 0xb7ede69e in libnm_glib_dbus_worker (user_data=0x818aca8)
> at libnm_glib.c:401
> #13 0x4ab825a2 in g_static_private_free ()
> from /usr/lib/libglib-2.0.so.0
> #14 0x47a57341 in start_thread ()
> from /lib/tls/i686/cmov/libpthread.so.0
> ---Type <return> to continue, or q <return> to quit---
> #15 0x479ab4ee in clone () from /lib/tls/i686/cmov/libc.so.6
>
> Thread 1 (Thread -1209166144 (LWP 27296)):
> #0 0xffffe410 in __kernel_vsyscall ()
> #1 0x47a5cd56 in __nanosleep_nocancel ()
> from /lib/tls/i686/cmov/libpthread.so.0
> #2 0x4ab84b04 in g_usleep () from /usr/lib/libglib-2.0.so.0
> #3 0xb7ede8d3 in libnm_glib_init () at libnm_glib.c:488
> #4 0xb7f210f2 in gaim_network_init () at network.c:600
> #5 0xb7f163b5 in gaim_core_init (ui=0x80d2a6d "gtk-gaim") at core.c:128
> #6 0x080a8b30 in main (argc=1, argv=0xbfa98e84) at gtkmain.c:706
>
> Richard
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]