2007-12-17 Dan Williams <dcbw@redhat.com>

* configure.in
		- Bump requirement for libnl to 1.0-pre8 (which works with newer kernels
			and fixes memory leaks)

	* src/nm-netlink.c
		- (nm_netlink_get_default_handle): handle new versions of libnl that
			automatically handle the netlink PID



git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@3178 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
This commit is contained in:
Dan Williams 2007-12-18 03:44:29 +00:00
parent f99d428711
commit e53989c673
3 changed files with 26 additions and 19 deletions

View file

@ -1,3 +1,13 @@
2007-12-17 Dan Williams <dcbw@redhat.com>
* configure.in
- Bump requirement for libnl to 1.0-pre8 (which works with newer kernels
and fixes memory leaks)
* src/nm-netlink.c
- (nm_netlink_get_default_handle): handle new versions of libnl that
automatically handle the netlink PID
2007-12-17 Dan Williams <dcbw@redhat.com>
Patch from Michael Biebl <biebl@debian.org>

View file

@ -187,7 +187,7 @@ PKG_CHECK_MODULES(HAL, hal >= 0.5.0)
AC_SUBST(HAL_CFLAGS)
AC_SUBST(HAL_LIBS)
PKG_CHECK_MODULES(LIBNL, libnl-1)
PKG_CHECK_MODULES(LIBNL, libnl-1 >= 1.0-pre8)
AC_SUBST(LIBNL_CFLAGS)
AC_SUBST(LIBNL_LIBS)

View file

@ -58,36 +58,33 @@ get_link_cache (void)
struct nl_handle *
nm_netlink_get_default_handle (void)
{
pid_t nl_pid;
int i = 10;
struct nl_cb *cb;
if (def_nl_handle)
return def_nl_handle;
while (i-- > 0) {
nl_pid = g_random_int ();
/* Ensure we don't use the same netlink pid as nm-netlink-monitor.c */
if (nl_pid != getpid ())
break;
}
if (G_UNLIKELY (i <= 0)) {
nm_warning ("couldn't get unused netlink pid.");
return NULL;
}
def_nl_handle = nl_handle_alloc_nondefault (NL_CB_VERBOSE);
cb = nl_cb_alloc(NL_CB_VERBOSE);
def_nl_handle = nl_handle_alloc_cb (cb);
if (!def_nl_handle) {
nm_warning ("couldn't allocate netlink handle.");
return NULL;
}
nl_handle_set_pid (def_nl_handle, nl_pid);
if (nl_connect (def_nl_handle, NETLINK_ROUTE) < 0) {
nm_error ("couldn't connect to netlink: %s", nl_geterror ());
/* HACK: try one more time. Because the netlink monitor for link state
* inits before we get here, it grabs the port that matches the PID
* of the NM process, which also happens to be the PID that libnl uses
* the first time too. The real fix is to convert nm-netlink-monitor.c
* over to use libnl.
*/
nl_handle_destroy (def_nl_handle);
def_nl_handle = NULL;
return NULL;
def_nl_handle = nm_netlink_get_default_handle ();
if (!def_nl_handle) {
nm_error ("couldn't connect to netlink: %s", nl_geterror ());
return NULL;
}
}
return def_nl_handle;