summaryrefslogtreecommitdiffstats
path: root/NetworkPkg/HttpBootDxe/HttpBootSupport.c
diff options
context:
space:
mode:
authorJiaxin Wu <jiaxin.wu@intel.com>2016-05-31 22:17:28 +0800
committerJiaxin Wu <jiaxin.wu@intel.com>2016-06-13 11:51:58 +0800
commit7570696c57d446f163050c2befb78b8fc6cfeb02 (patch)
treedb3ccfbe7b9a202cd7bfd81e40f358023d7a2be9 /NetworkPkg/HttpBootDxe/HttpBootSupport.c
parent30526a51dda7e8db483f22a045f32f3a18eea5c7 (diff)
downloadedk2-7570696c57d446f163050c2befb78b8fc6cfeb02.tar.gz
edk2-7570696c57d446f163050c2befb78b8fc6cfeb02.tar.bz2
edk2-7570696c57d446f163050c2befb78b8fc6cfeb02.zip
NetworkPkg: Handling timeout case in httpboot driver
This patch is used to handle timeout case when downloading the message. The Status in the token should also be checked to handle any response error case including timeout case. Cc: Fu Siyuan <siyuan.fu@intel.com> Cc: Ye Ting <ting.ye@intel.com> Cc: Zhang Lubo <lubo.zhang@intel.com> Cc: Hegde Nagaraj P <nagaraj-p.hegde@hpe.com> Cc: Gary Lin <glin@suse.com> Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Jiaxin Wu <jiaxin.wu@intel.com> Reviewed-by: Gary Lin <glin@suse.com> Reviewed-by: Hegde Nagaraj P <nagaraj-p.hegde@hpe.com> Reviewed-by: Ye Ting <ting.ye@intel.com> Tested-by: Gary Lin <glin@suse.com> Tested-by: Hegde Nagaraj P <nagaraj-p.hegde@hpe.com>
Diffstat (limited to 'NetworkPkg/HttpBootDxe/HttpBootSupport.c')
-rw-r--r--NetworkPkg/HttpBootDxe/HttpBootSupport.c46
1 files changed, 45 insertions, 1 deletions
diff --git a/NetworkPkg/HttpBootDxe/HttpBootSupport.c b/NetworkPkg/HttpBootDxe/HttpBootSupport.c
index 66eca783af..9410bf9e15 100644
--- a/NetworkPkg/HttpBootDxe/HttpBootSupport.c
+++ b/NetworkPkg/HttpBootDxe/HttpBootSupport.c
@@ -754,6 +754,21 @@ HttpIoCreateIo (
HttpIo->RspToken.Event = Event;
HttpIo->RspToken.Message = &HttpIo->RspMessage;
+ //
+ // Create TimeoutEvent for response
+ //
+ Status = gBS->CreateEvent (
+ EVT_TIMER,
+ TPL_CALLBACK,
+ NULL,
+ NULL,
+ &Event
+ );
+ if (EFI_ERROR (Status)) {
+ goto ON_ERROR;
+ }
+ HttpIo->TimeoutEvent = Event;
+
return EFI_SUCCESS;
ON_ERROR:
@@ -789,6 +804,11 @@ HttpIoDestroyIo (
if (Event != NULL) {
gBS->CloseEvent (Event);
}
+
+ Event = HttpIo->TimeoutEvent;
+ if (Event != NULL) {
+ gBS->CloseEvent (Event);
+ }
Http = HttpIo->Http;
if (Http != NULL) {
@@ -903,6 +923,14 @@ HttpIoRecvResponse (
}
//
+ // Start the timer, and wait Timeout seconds to receive the header packet.
+ //
+ Status = gBS->SetTimer (HttpIo->TimeoutEvent, TimerRelative, HTTP_BOOT_RESPONSE_TIMEOUT * TICKS_PER_MS);
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+
+ //
// Queue the response token to HTTP instances.
//
HttpIo->RspToken.Status = EFI_NOT_READY;
@@ -924,16 +952,32 @@ HttpIoRecvResponse (
);
if (EFI_ERROR (Status)) {
+ gBS->SetTimer (HttpIo->TimeoutEvent, TimerCancel, 0);
return Status;
}
//
// Poll the network until receive finish.
//
- while (!HttpIo->IsRxDone) {
+ while (!HttpIo->IsRxDone && ((HttpIo->TimeoutEvent == NULL) || EFI_ERROR (gBS->CheckEvent (HttpIo->TimeoutEvent)))) {
Http->Poll (Http);
}
+ gBS->SetTimer (HttpIo->TimeoutEvent, TimerCancel, 0);
+
+ if (!HttpIo->IsRxDone) {
+ //
+ // Timeout occurs, cancel the response token.
+ //
+ Http->Cancel (Http, &HttpIo->RspToken);
+
+ Status = EFI_TIMEOUT;
+
+ return Status;
+ } else {
+ HttpIo->IsRxDone = FALSE;
+ }
+
//
// Store the received data into the wrapper.
//