[srp-server] ensure to clear mHasRegisteredAnyService on server stop (#6763)

This commit updates `Srp::Server` to clear `mHasRegisteredAnyService`
when server is stopped and all the hosts and services are deleted.
This boolean flag is used to save the port number in non-volatile
settings so that we can ensure to pick a different port number the
next time the server starts.

This change addresses an issue where the port number may not be saved
and therefore not changed if the server is stopped and restarted
two times in a row.
This commit is contained in:
Abtin Keshavarzian
2021-06-24 10:28:08 -07:00
committed by Jonathan Hui
parent b11d0d2205
commit 7799bae4ef
+1
View File
@@ -487,6 +487,7 @@ void Server::Stop(void)
otLogInfoSrp("[server] stop listening on %hu", mSocket.GetSockName().mPort);
IgnoreError(mSocket.Close());
mHasRegisteredAnyService = false;
exit:
return;