49158d
commit 		17c9787b1d6891636b5be9e4e5a08278b44e9a7a
49158d
Author: 	Miroslav Lichvar <mlichvar@redhat.com>
49158d
Date: 		Fri Sep 01 11:42:26 2017 +0100
49158d
49158d
		phc2sys: fix handling of multiple state changes.
49158d
49158d
		When the master clock changed its state and then changed it back to the
49158d
		original state before phc2sys could process the first change, e.g. SLAVE
49158d
		-> UNCALIBRATED -> SLAVE after a clockcheck failure, the second change
49158d
		was ignored because the new value was the same as the original state,
49158d
		which wasn't updated for the first change yet. This caused phc2sys to be
49158d
		stuck with a wrong state.
49158d
49158d
		Fix phc2sys to check both the state and new_state variables of the clock.
49158d
49158d
		Signed-off-by: Miroslav Lichvar <mlichvar@redhat.com>
49158d
49158d
diff --git a/phc2sys.c b/phc2sys.c
49158d
index b6f6719..e2b5c47 100644
49158d
--- a/phc2sys.c
49158d
+++ b/phc2sys.c
49158d
@@ -786,7 +786,7 @@ static int recv_subscribed(struct node *node, struct ptp_message *msg,
49158d
 			port->state = state;
49158d
 			clock = port->clock;
49158d
 			state = clock_compute_state(node, clock);
49158d
-			if (clock->state != state) {
49158d
+			if (clock->state != state || clock->new_state) {
49158d
 				clock->new_state = state;
49158d
 				node->state_changed = 1;
49158d
 			}