blob: 26a54e7bf9347a0a45968fbebe32251a1e6e9047 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
|
=== modified file 'src/NetworkManagerSystem.c'
--- src/NetworkManagerSystem.c 2007-12-20 06:06:27 +0000
+++ src/NetworkManagerSystem.c 2007-12-20 06:57:47 +0000
@@ -224,16 +224,33 @@
static struct nl_handle * new_nl_handle (void)
{
- struct nl_handle * nlh = NULL;
-
- nlh = nl_handle_alloc_nondefault(NL_CB_VERBOSE);
- nl_handle_set_pid (nlh, (pthread_self() << 16 | getpid()));
- if (nl_connect(nlh, NETLINK_ROUTE) < 0)
- {
- nm_warning ("%s: couldn't connecto to netlink: %s", __func__, nl_geterror());
+ struct nl_handle * nlh = NULL;
+ struct nl_cb *cb;
+
+ cb = nl_cb_alloc (NL_CB_VERBOSE);
+ nlh = nl_handle_alloc_cb (cb);
+
+ if (!nlh) {
+ nm_warning ("couldn't allocate netlink handle.");
+ return NULL;
+ }
+
+ if (nl_connect (nlh, NETLINK_ROUTE) < 0) {
+ /* 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 (nlh);
nlh = NULL;
- }
+
+ nlh = new_nl_handle ();
+ if (!nlh) {
+ nm_error ("couldn't connect to netlink: %s", nl_geterror ());
+ return NULL;
+ }
+ }
return nlh;
}
|