Skip to content

Commit

Permalink
Initial events are occasionally failing to be delivered - the tcp con…
Browse files Browse the repository at this point in the history
…nect attempt from the device stack is never acknowledged by the network stack on the control point. This can cause control point's discovery to fail. Mitigate this by retrying the connect for initial events. See #4469.
  • Loading branch information
SimonChisholm committed Aug 19, 2016
1 parent bd9c14d commit 1d7bd01
Showing 1 changed file with 25 additions and 3 deletions.
28 changes: 25 additions & 3 deletions OpenHome/Net/Device/Upnp/DviServerUpnp.cpp
Expand Up @@ -336,9 +336,31 @@ void PropertyWriterUpnp::Connect()
iSubscriber.AppendAddress(buf);
Log::Print("PropertyWriterUpnp connecting to %s\n", buf.Ptr());
#endif
iSocket.Open(iEnv);
iSocket.Connect(iSubscriber, iEnv.InitParams()->TcpConnectTimeoutMs());
//iSocket.LogVerbose(true);
static const TUint kInitialEventConnectRetries = 3;
TUint retries = (iSequenceNumber == 0? kInitialEventConnectRetries : 0);
for (;;) {
try {
iSocket.Open(iEnv);
iSocket.Connect(iSubscriber, iEnv.InitParams()->TcpConnectTimeoutMs());
//iSocket.LogVerbose(true);
return;
}
catch (NetworkTimeout&) {
if (retries == 0) {
throw;
}
}
catch (NetworkError&) {
if (retries == 0) {
throw;
}
}
--retries;
try {
iSocket.Close();
}
catch (NetworkError&) {}
}
}

void PropertyWriterUpnp::WriteHeaders(TUint aContentLength)
Expand Down

0 comments on commit 1d7bd01

Please sign in to comment.