diff options
author | Anurag S. Maskey <Anurag.Maskey@Oracle.COM> | 2010-06-01 17:33:59 -0400 |
---|---|---|
committer | Anurag S. Maskey <Anurag.Maskey@Oracle.COM> | 2010-06-01 17:33:59 -0400 |
commit | ea408ca7befa82c08eb7affd8f29f1692188f34a (patch) | |
tree | ea858be1702b426e1190021f6076d9b17b1713be /usr/src | |
parent | 1f10d449561c68a9cd8fbba556489f89a1138415 (diff) | |
download | illumos-gate-ea408ca7befa82c08eb7affd8f29f1692188f34a.tar.gz |
6953920 switching from Automatic location briefly activates Automatic location
Diffstat (limited to 'usr/src')
-rw-r--r-- | usr/src/cmd/cmd-inet/lib/nwamd/loc.c | 27 | ||||
-rw-r--r-- | usr/src/lib/libnwam/common/libnwam_loc.c | 11 |
2 files changed, 26 insertions, 12 deletions
diff --git a/usr/src/cmd/cmd-inet/lib/nwamd/loc.c b/usr/src/cmd/cmd-inet/lib/nwamd/loc.c index 3005a4669e..d1f670402b 100644 --- a/usr/src/cmd/cmd-inet/lib/nwamd/loc.c +++ b/usr/src/cmd/cmd-inet/lib/nwamd/loc.c @@ -418,7 +418,7 @@ nwamd_loc_handle_init_event(nwamd_event_t event) nwamd_object_t object; nwam_loc_handle_t loch; nwam_error_t err; - boolean_t manual_disabled = B_FALSE; + boolean_t new_enabled, old_enabled = B_FALSE; nwam_state_t state; if ((err = nwam_loc_read(event->event_object, 0, &loch)) @@ -431,6 +431,7 @@ nwamd_loc_handle_init_event(nwamd_event_t event) } if ((object = nwamd_object_find(NWAM_OBJECT_TYPE_LOC, event->event_object)) != NULL) { + old_enabled = loc_is_enabled(object->nwamd_object_handle); nwam_loc_free(object->nwamd_object_handle); object->nwamd_object_handle = loch; } else { @@ -440,18 +441,19 @@ nwamd_loc_handle_init_event(nwamd_event_t event) object->nwamd_object_aux_state = NWAM_AUX_STATE_CONDITIONS_NOT_MET; } - manual_disabled = (loc_get_activation_mode(loch) == - NWAM_ACTIVATION_MODE_MANUAL && !loc_is_enabled(loch)); + new_enabled = loc_is_enabled(loch); state = object->nwamd_object_state; nwamd_object_release(object); /* - * If this location is ONLINE, and not manual and disabled (since in - * that case it was online but we've just set enabled = false as part - * of a disable action), then it is still active but refreshing. - * Change states to re-activate itself. + * If this location is ONLINE and the value of the "enabled" property + * has not changed, then this location is getting refreshed because it + * was committed with changes. Change states to re-activate itself. + * If the "enabled" property has changed, then this location is + * getting refreshed as part of a enable/disable action and there is + * no need to change states here. */ - if (!manual_disabled && state == NWAM_STATE_ONLINE) { + if (state == NWAM_STATE_ONLINE && old_enabled == new_enabled) { nwamd_object_set_state(NWAM_OBJECT_TYPE_LOC, event->event_object, NWAM_STATE_OFFLINE_TO_ONLINE, NWAM_AUX_STATE_METHOD_RUNNING); @@ -591,8 +593,15 @@ nwamd_loc_handle_state_event(nwamd_event_t event) case NWAM_STATE_ONLINE_TO_OFFLINE: /* * Don't need to deactivate current location - condition check - * will activate another. + * will activate another. If the currently active location is + * being deactivated, then it is being manually deactivated; + * so also clear active_loc so condition checking is not + * confused. */ + (void) pthread_mutex_lock(&active_loc_mutex); + if (strcmp(event->event_object, active_loc) == 0) + active_loc[0] = '\0'; + (void) pthread_mutex_unlock(&active_loc_mutex); nwamd_loc_check_conditions(); break; case NWAM_STATE_DISABLED: diff --git a/usr/src/lib/libnwam/common/libnwam_loc.c b/usr/src/lib/libnwam/common/libnwam_loc.c index 6215876792..23adbba00b 100644 --- a/usr/src/lib/libnwam/common/libnwam_loc.c +++ b/usr/src/lib/libnwam/common/libnwam_loc.c @@ -20,8 +20,7 @@ */ /* - * Copyright 2010 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. + * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. */ #include <assert.h> @@ -1066,7 +1065,7 @@ static int loc_set_enabled(nwam_loc_handle_t loch, void *data) { nwam_value_t enabledval; - boolean_t enabled = B_FALSE; + boolean_t curr_state, enabled = B_FALSE; nwam_loc_handle_t testloch = data; nwam_error_t err = NWAM_SUCCESS; @@ -1080,6 +1079,12 @@ loc_set_enabled(nwam_loc_handle_t loch, void *data) enabled = B_TRUE; } } + + /* If the enabled property is not changing, don't do anything. */ + if (nwam_loc_is_enabled(loch, &curr_state) == NWAM_SUCCESS && + curr_state == enabled) + return (0); + if (nwam_value_create_boolean(enabled, &enabledval) != NWAM_SUCCESS) return (0); if (nwam_set_prop_value(loch->nwh_data, NWAM_LOC_PROP_ENABLED, |