Skip to content

Commit

Permalink
[srp-client] improve Client::Start error handling (openthread#10834)
Browse files Browse the repository at this point in the history
SRP Client close socket on connect error to avoid to fail the next time.
  • Loading branch information
GLegoupil authored Oct 16, 2024
1 parent a225ee9 commit 3a037f2
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/core/net/srp_client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,15 @@ Error Client::Start(const Ip6::SockAddr &aServerSockAddr, Requester aRequester)
error = (aServerSockAddr == GetServerAddress()) ? kErrorNone : kErrorBusy);

SuccessOrExit(error = mSocket.Open());
SuccessOrExit(error = mSocket.Connect(aServerSockAddr));

error = mSocket.Connect(aServerSockAddr);
if (error != kErrorNone)
{
LogInfo("Failed to connect to server %s: %s", aServerSockAddr.GetAddress().ToString().AsCString(),
ErrorToString(error));
IgnoreError(mSocket.Close());
ExitNow();
}

LogInfo("%starting, server %s", (aRequester == kRequesterUser) ? "S" : "Auto-s",
aServerSockAddr.ToString().AsCString());
Expand Down

0 comments on commit 3a037f2

Please sign in to comment.