/[gentoo-x86]/net-misc/networkmanager/files/networkmanager-0.9.1.90-rfkill.patch
Gentoo

Contents of /net-misc/networkmanager/files/networkmanager-0.9.1.90-rfkill.patch

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.2 - (show annotations) (download)
Sun Nov 13 23:19:00 2011 UTC (2 years, 9 months ago) by tetromino
Branch: MAIN
CVS Tags: HEAD
Changes since 1.1: +0 -0 lines
FILE REMOVED
Bump, drop old. First stable release in the 0.9.2 series.

(Portage version: 2.2.0_alpha74/cvs/Linux x86_64)

1 From 339229e4c698c61e20a28bfc33d8501490891427 Mon Sep 17 00:00:00 2001
2 From: Gary Ching-Pang Lin <chingpang@gmail.com>
3 Date: Tue, 20 Sep 2011 08:36:35 +0000
4 Subject: core: improving handling of rfkill (bgo #655773)
5
6 This commit improves the handling of rfkill.
7
8 - The original two passes check gathers the states of platform
9 and non-platform switches in two separate loops. Now we gather
10 the both states in one loop and determine the final states later.
11
12 - A new rule is used to determine the states of switches.
13
14 if (platform_state == UNBLOCKED)
15 choose non_platform_state;
16 else
17 choose platform_state;
18
19 The state is UNBLOCKED if and only if both the platform and
20 non-platform switches are unblocked, so the ambiguous state in
21 bgo#655773 will not happen.
22
23 Original code always preferred the platform switch state over
24 the device switch state, so if the platform switch was UNBLOCKED
25 but the device was BLOCKED, NM would treat the device as
26 UNBLOCKED and try to activate it, and obviously fail.
27 ---
28 diff --git a/src/nm-udev-manager.c b/src/nm-udev-manager.c
29 index 72501c2..3e855b7 100644
30 --- a/src/nm-udev-manager.c
31 +++ b/src/nm-udev-manager.c
32 @@ -195,78 +195,50 @@ recheck_killswitches (NMUdevManager *self)
33 NMUdevManagerPrivate *priv = NM_UDEV_MANAGER_GET_PRIVATE (self);
34 GSList *iter;
35 RfKillState poll_states[RFKILL_TYPE_MAX];
36 + RfKillState platform_states[RFKILL_TYPE_MAX];
37 gboolean platform_checked[RFKILL_TYPE_MAX];
38 int i;
39
40 /* Default state is unblocked */
41 for (i = 0; i < RFKILL_TYPE_MAX; i++) {
42 poll_states[i] = RFKILL_UNBLOCKED;
43 + platform_states[i] = RFKILL_UNBLOCKED;
44 platform_checked[i] = FALSE;
45 }
46
47 - /* Perform two passes here; the first pass is for non-platform switches,
48 - * which typically if hardkilled cannot be changed except by a physical
49 - * hardware switch. The second pass checks platform killswitches, which
50 - * take precedence over device killswitches, because typically platform
51 - * killswitches control device killswitches. That is, a hardblocked device
52 - * switch can often be unblocked by a platform switch. Thus if we have
53 - * a hardblocked device switch and a softblocked platform switch, the
54 - * combined state should be softblocked since the platform switch can be
55 - * unblocked to change the device switch.
56 - */
57 -
58 - /* Device switches first */
59 + /* Poll the states of all killswitches */
60 for (iter = priv->killswitches; iter; iter = g_slist_next (iter)) {
61 Killswitch *ks = iter->data;
62 GUdevDevice *device;
63 RfKillState dev_state;
64 int sysfs_state;
65
66 - if (ks->platform == FALSE) {
67 - device = g_udev_client_query_by_subsystem_and_name (priv->client, "rfkill", ks->name);
68 - if (device) {
69 - sysfs_state = g_udev_device_get_property_as_int (device, "RFKILL_STATE");
70 - dev_state = sysfs_state_to_nm_state (sysfs_state);
71 + device = g_udev_client_query_by_subsystem_and_name (priv->client, "rfkill", ks->name);
72 + if (device) {
73 + sysfs_state = g_udev_device_get_property_as_int (device, "RFKILL_STATE");
74 + dev_state = sysfs_state_to_nm_state (sysfs_state);
75 + if (ks->platform == FALSE) {
76 if (dev_state > poll_states[ks->rtype])
77 poll_states[ks->rtype] = dev_state;
78 - g_object_unref (device);
79 - }
80 - }
81 - }
82 -
83 - /* Platform switches next; their state overwrites device state */
84 - for (iter = priv->killswitches; iter; iter = g_slist_next (iter)) {
85 - Killswitch *ks = iter->data;
86 - GUdevDevice *device;
87 - RfKillState dev_state;
88 - int sysfs_state;
89 -
90 - if (ks->platform == TRUE) {
91 - device = g_udev_client_query_by_subsystem_and_name (priv->client, "rfkill", ks->name);
92 - if (device) {
93 - sysfs_state = g_udev_device_get_property_as_int (device, "RFKILL_STATE");
94 - dev_state = sysfs_state_to_nm_state (sysfs_state);
95 -
96 - if (platform_checked[ks->rtype] == FALSE) {
97 - /* Overwrite device state with platform state for first
98 - * platform switch found.
99 - */
100 - poll_states[ks->rtype] = dev_state;
101 - platform_checked[ks->rtype] = TRUE;
102 - } else {
103 - /* If there are multiple platform switches of the same type,
104 - * take the "worst" state for all of that type.
105 - */
106 - if (dev_state > poll_states[ks->rtype])
107 - poll_states[ks->rtype] = dev_state;
108 - }
109 - g_object_unref (device);
110 + } else {
111 + platform_checked[ks->rtype] = TRUE;
112 + if (dev_state > platform_states[ks->rtype])
113 + platform_states[ks->rtype] = dev_state;
114 }
115 + g_object_unref (device);
116 }
117 }
118
119 /* Log and emit change signal for final rfkill states */
120 for (i = 0; i < RFKILL_TYPE_MAX; i++) {
121 + if (platform_checked[i] == TRUE) {
122 + /* blocked platform switch state overrides device state, otherwise
123 + * let the device state stand. (bgo #655773)
124 + */
125 + if (platform_states[i] != RFKILL_UNBLOCKED)
126 + poll_states[i] = platform_states[i];
127 + }
128 +
129 if (poll_states[i] != priv->rfkill_states[i]) {
130 nm_log_dbg (LOGD_RFKILL, "%s rfkill state now '%s'",
131 rfkill_type_to_desc (i),
132 --
133 cgit v0.9.0.2-2-gbebe

  ViewVC Help
Powered by ViewVC 1.1.20