On Fri, May 20, 2016 at 03:24:29PM +0800, Jiaxin Wu wrote:
> Http token status should be updated to EFI_TIMEOUT while timeout
> happened by any abruptly interrupted (e.g. network disconnection,
> cable plug/unplug...). Otherwise, HttpBootDxe driver will continue
> treat it as no error happened, and its ReceivedSize will be updated
> to ContentLength directly. Moreover, If download image type is RAM
> Disk, the corresponding info will be registered to system.
> 
Hi Jiaxin,

I just tested the patch. It works well for me.

Here is how the patch was tested.
I started OVMF to connect to the host with a tap interface with IP
address 192.168.111.1 and then started the dhcp and http server on the
host. A new HTTP boot entry was created from HII to download a 2.9 GB
iso file. When OVMF was downloading the iso, I changed the IP to
192.168.100.1 to make the timeout deliberately. After applying the
patch, OVMF went back to the BDS HII as expected. What's interesting is
that, before applying the patch, OVMF just loaded the unfinished iso,
created a RAMDISK, and loaded the bootloader. It's probably because that
HttpTcpReceiveBody always returned EFI_SUCCESS.

So, the patch does a good work :)
Just one nitpicking thing: the line below HttpCloseConnection introdued
trailing whitespaces.

Reviewed-by: Gary Lin <g...@suse.com> and Tested-by: Gary Lin <g...@suse.com>

Cheers,

Gary Lin

> Cc: Ye Ting <ting...@intel.com>
> Cc: Fu Siyuan <siyuan...@intel.com>
> Cc: Gary Lin <g...@suse.com>
> Cc: Samer El-Haj-Mahmoud <el...@hpe.com>
> Cc: Hegde Nagaraj P <nagaraj-p.he...@hpe.com>
> Contributed-under: TianoCore Contribution Agreement 1.0
> Signed-off-by: Jiaxin Wu <jiaxin...@intel.com>
> ---
>  NetworkPkg/HttpDxe/HttpImpl.c  |  3 +++
>  NetworkPkg/HttpDxe/HttpProto.c | 16 +++++++++++-----
>  2 files changed, 14 insertions(+), 5 deletions(-)
> 
> diff --git a/NetworkPkg/HttpDxe/HttpImpl.c b/NetworkPkg/HttpDxe/HttpImpl.c
> index f4ae28a..05a96e9 100644
> --- a/NetworkPkg/HttpDxe/HttpImpl.c
> +++ b/NetworkPkg/HttpDxe/HttpImpl.c
> @@ -1259,10 +1259,13 @@ Exit:
>  
>  Error2:
>    NetMapInsertHead (&HttpInstance->TxTokens, ValueInItem->HttpToken, 
> ValueInItem);
>  
>  Error:
> +
> +  HttpCloseConnection (HttpInstance);
> +  
>    HttpTcpTokenCleanup (Wrap);
>    
>    if (HttpHeaders != NULL) {
>      FreePool (HttpHeaders);
>    }
> diff --git a/NetworkPkg/HttpDxe/HttpProto.c b/NetworkPkg/HttpDxe/HttpProto.c
> index afa7fe4..c3608c0 100644
> --- a/NetworkPkg/HttpDxe/HttpProto.c
> +++ b/NetworkPkg/HttpDxe/HttpProto.c
> @@ -1,9 +1,9 @@
>  /** @file
>    Miscellaneous routines for HttpDxe driver.
>  
> -Copyright (c) 2015, Intel Corporation. All rights reserved.<BR>
> +Copyright (c) 2015 - 2016, Intel Corporation. All rights reserved.<BR>
>  (C) Copyright 2016 Hewlett Packard Enterprise Development LP<BR>
>  This program and the accompanying materials
>  are licensed and made available under the terms and conditions of the BSD 
> License
>  which accompanies this distribution.  The full text of the license may be 
> found at
>  http://opensource.org/licenses/bsd-license.php
> @@ -1605,10 +1605,11 @@ HttpTcpReceiveHeader (
>        while (!HttpInstance->IsRxDone && ((Timeout == NULL) || EFI_ERROR 
> (gBS->CheckEvent (Timeout)))) {
>          Tcp4->Poll (Tcp4);
>        }
>  
>        if (!HttpInstance->IsRxDone) {
> +        Tcp4->Cancel (Tcp4, &Rx4Token->CompletionToken);
>          gBS->CloseEvent (Rx4Token->CompletionToken.Event);
>          Rx4Token->CompletionToken.Status = EFI_TIMEOUT;
>        }
>    
>        Status = Rx4Token->CompletionToken.Status;
> @@ -1671,10 +1672,11 @@ HttpTcpReceiveHeader (
>        while (!HttpInstance->IsRxDone && ((Timeout == NULL) || EFI_ERROR 
> (gBS->CheckEvent (Timeout)))) {
>          Tcp6->Poll (Tcp6);
>        }
>  
>        if (!HttpInstance->IsRxDone) {
> +        Tcp6->Cancel (Tcp6, &Rx6Token->CompletionToken);
>          gBS->CloseEvent (Rx6Token->CompletionToken.Event);
>          Rx6Token->CompletionToken.Status = EFI_TIMEOUT;
>        }
>    
>        Status = Rx6Token->CompletionToken.Status;
> @@ -1745,11 +1747,12 @@ HttpTcpReceiveBody (
>    HTTP_PROTOCOL             *HttpInstance;
>    EFI_TCP6_PROTOCOL         *Tcp6;
>    EFI_TCP6_IO_TOKEN         *Rx6Token;
>    EFI_TCP4_PROTOCOL         *Tcp4;
>    EFI_TCP4_IO_TOKEN         *Rx4Token;
> -  
> +
> +  Status = EFI_SUCCESS;
>    HttpInstance   = Wrap->HttpInstance;
>    Tcp4 = HttpInstance->Tcp4;
>    Tcp6 = HttpInstance->Tcp6;
>    Rx4Token       = NULL;
>    Rx6Token       = NULL;
> @@ -1776,14 +1779,15 @@ HttpTcpReceiveBody (
>      while (!Wrap->TcpWrap.IsRxDone && ((Timeout == NULL) || EFI_ERROR 
> (gBS->CheckEvent (Timeout)))) {
>        Tcp6->Poll (Tcp6);
>      }
>  
>      if (!Wrap->TcpWrap.IsRxDone) {
> +      Tcp6->Cancel (Tcp6, &Rx6Token->CompletionToken);
>        gBS->CloseEvent (Rx6Token->CompletionToken.Event);
> +      Rx6Token->CompletionToken.Event = NULL;
>        Rx6Token->CompletionToken.Status = EFI_TIMEOUT;
>        Wrap->HttpToken->Status = Rx6Token->CompletionToken.Status;
> -      gBS->SignalEvent (Wrap->HttpToken->Event);
>      }
>    } else {
>      Rx4Token = &Wrap->TcpWrap.Rx4Token;
>      Rx4Token->Packet.RxData->DataLength = (UINT32) HttpMsg->BodyLength;
>      Rx4Token->Packet.RxData->FragmentTable[0].FragmentLength = (UINT32) 
> HttpMsg->BodyLength;
> @@ -1799,19 +1803,21 @@ HttpTcpReceiveBody (
>      while (!Wrap->TcpWrap.IsRxDone && ((Timeout == NULL) || EFI_ERROR 
> (gBS->CheckEvent (Timeout)))) {
>        Tcp4->Poll (Tcp4);
>      }
>  
>      if (!Wrap->TcpWrap.IsRxDone) {
> +      Tcp4->Cancel (Tcp4, &Rx4Token->CompletionToken);
>        gBS->CloseEvent (Rx4Token->CompletionToken.Event);
> +      Rx4Token->CompletionToken.Event = NULL;
>        Rx4Token->CompletionToken.Status = EFI_TIMEOUT;
>        Wrap->HttpToken->Status = Rx4Token->CompletionToken.Status;
> -      gBS->SignalEvent (Wrap->HttpToken->Event);
>      }
>    }
>  
> -  return EFI_SUCCESS;
> +  Status = Wrap->HttpToken->Status;
>  
> +  return Status;
>  }
>  
>  /**
>    Clean up Tcp Tokens while the Tcp transmission error occurs.
>  
> -- 
> 1.9.5.msysgit.1
> 
> 
_______________________________________________
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel

Reply via email to