From 57e2f4e26d9ee9e40e014e18c4276e012db1166e Mon Sep 17 00:00:00 2001 From: Abtin Keshavarzian Date: Thu, 31 Jan 2019 13:03:02 -0800 Subject: [PATCH] [mle] stop attach timer from SetStateChild() (#3538) This commit changes `SetStateChild()` to stop `mAttachTimer`. This ensures that as the `mAttachState` is set to idle, the attach timer is also stopped (note that the attach timer callback asserts on idle attach state). This addresses a rare issue where an inopportune device mode change request on an already attached device while it is performing periodic parent search (or possibly delaying processing of a received announce) could cause an assert; `SetDeviceMode()` would call `SetStateChild()` setting the attach state to idle while attach timer would continue to run. --- src/core/thread/mle.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/core/thread/mle.cpp b/src/core/thread/mle.cpp index 495aae04a..5d07d3dcc 100644 --- a/src/core/thread/mle.cpp +++ b/src/core/thread/mle.cpp @@ -737,6 +737,7 @@ void Mle::SetStateChild(uint16_t aRloc16) SetRloc16(aRloc16); SetRole(OT_DEVICE_ROLE_CHILD); SetAttachState(kAttachStateIdle); + mAttachTimer.Stop(); mAttachCounter = 0; mReattachState = kReattachStop; mChildUpdateAttempts = 0;