If the 2nd boot quickly after the first succeed boot, it will function well, but if you wait for some time and boot again, until the TCP state changed from established to closed wait as the http server send fin flag, then boot fail occurred.
Cc: Ye Ting <ting...@intel.com> Cc: Fu Siyuan <siyuan...@intel.com> CC: Wu Jiaxin <jiaxin...@intel.com> Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Zhang Lubo <lubo.zh...@intel.com> --- NetworkPkg/HttpDxe/HttpImpl.c | 19 +++++++++++++++++++ NetworkPkg/HttpDxe/HttpProto.c | 17 ++++++++++++----- 2 files changed, 31 insertions(+), 5 deletions(-) diff --git a/NetworkPkg/HttpDxe/HttpImpl.c b/NetworkPkg/HttpDxe/HttpImpl.c index 2f4ce89..aec5cf7 100644 --- a/NetworkPkg/HttpDxe/HttpImpl.c +++ b/NetworkPkg/HttpDxe/HttpImpl.c @@ -460,10 +460,29 @@ EfiHttpRequest ( goto Error1; } } // + // Check existing TCP connection, if in error state, recover TCP connection. + // + if (!Configure) { + if (HttpInstance->LocalAddressIsIPv6) { + Status = HttpConnectTcp6 (HttpInstance); + if (EFI_ERROR (Status)) { + return Status; + } + + } else { + Status = HttpConnectTcp4 (HttpInstance); + if (EFI_ERROR (Status)) { + return Status; + } + } + + } + + // // Create request message. // FileUrl = Url; if (*FileUrl != '/') { // diff --git a/NetworkPkg/HttpDxe/HttpProto.c b/NetworkPkg/HttpDxe/HttpProto.c index 39837a3..d22e33e 100644 --- a/NetworkPkg/HttpDxe/HttpProto.c +++ b/NetworkPkg/HttpDxe/HttpProto.c @@ -1175,13 +1175,12 @@ HttpConnectTcp4 ( IN HTTP_PROTOCOL *HttpInstance ) { EFI_STATUS Status; EFI_TCP4_CONNECTION_STATE Tcp4State; - - - if (HttpInstance->State != HTTP_STATE_TCP_CONFIGED || HttpInstance->Tcp4 == NULL) { + + if (HttpInstance->State < HTTP_STATE_TCP_CONFIGED || HttpInstance->Tcp4 == NULL) { return EFI_NOT_READY; } Status = HttpInstance->Tcp4->GetModeData( HttpInstance->Tcp4, @@ -1196,11 +1195,15 @@ HttpConnectTcp4 ( return Status; } if (Tcp4State > Tcp4StateEstablished) { HttpCloseConnection(HttpInstance); - } + } else { + if (HttpInstance->State == HTTP_STATE_TCP_CONNECTED) { + return EFI_SUCCESS; + } + } return HttpCreateConnection (HttpInstance); } /** @@ -1219,11 +1222,11 @@ HttpConnectTcp6 ( ) { EFI_STATUS Status; EFI_TCP6_CONNECTION_STATE Tcp6State; - if (HttpInstance->State != HTTP_STATE_TCP_CONFIGED || HttpInstance->Tcp6 == NULL) { + if (HttpInstance->State < HTTP_STATE_TCP_CONFIGED || HttpInstance->Tcp6 == NULL) { return EFI_NOT_READY; } Status = HttpInstance->Tcp6->GetModeData ( HttpInstance->Tcp6, @@ -1239,10 +1242,14 @@ HttpConnectTcp6 ( return Status; } if (Tcp6State > Tcp6StateEstablished) { HttpCloseConnection (HttpInstance); + } else { + if (HttpInstance->State == HTTP_STATE_TCP_CONNECTED) { + return EFI_SUCCESS; + } } return HttpCreateConnection (HttpInstance); } -- 1.9.5.msysgit.1 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel