diff options
author | Zhang Lubo <lubo.zhang@intel.com> | 2015-09-06 01:30:44 +0000 |
---|---|---|
committer | luobozhang <luobozhang@Edk2> | 2015-09-06 01:30:44 +0000 |
commit | 374ecd04505e028c2eba3f8368f7cd7079c7669f (patch) | |
tree | 678a0eeb7e9d950c08c83f9cfd3db927b17808b2 /NetworkPkg/HttpDxe | |
parent | 0a4f7aa05618fda721d3681164a5ac44cfe40d08 (diff) | |
download | edk2-platforms-374ecd04505e028c2eba3f8368f7cd7079c7669f.tar.xz |
NetworkPkg: Fix the HttpCloseConnection fail issue
When HTTP server is unavailable,HttpCloseConnection will enter
infinite loop to wait for TCP4->close Event return, So we need to
decide the Http Instance state whether in the appropriate state
before close it.
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Zhang Lubo <lubo.zhang@intel.com>
Reviewed-by: Fu Siyuan <siyuan.fu@intel.com>
Reviewed-by: Ye Ting <ting.ye@intel.com>
Reviewed-by: Wu Jiaxin <jiaxin.wu@intel.com>
git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@18400 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'NetworkPkg/HttpDxe')
-rw-r--r-- | NetworkPkg/HttpDxe/HttpImpl.c | 1 | ||||
-rw-r--r-- | NetworkPkg/HttpDxe/HttpProto.c | 25 |
2 files changed, 15 insertions, 11 deletions
diff --git a/NetworkPkg/HttpDxe/HttpImpl.c b/NetworkPkg/HttpDxe/HttpImpl.c index 5b3c5d058c..dc06b9855c 100644 --- a/NetworkPkg/HttpDxe/HttpImpl.c +++ b/NetworkPkg/HttpDxe/HttpImpl.c @@ -516,6 +516,7 @@ Error2: HttpCloseTcp4ConnCloseEvent (HttpInstance);
if (NULL != Wrap->TcpWrap.TxToken.CompletionToken.Event) {
gBS->CloseEvent (Wrap->TcpWrap.TxToken.CompletionToken.Event);
+ Wrap->TcpWrap.TxToken.CompletionToken.Event = NULL;
}
Error1:
diff --git a/NetworkPkg/HttpDxe/HttpProto.c b/NetworkPkg/HttpDxe/HttpProto.c index 829758ad5e..e8ce9879f3 100644 --- a/NetworkPkg/HttpDxe/HttpProto.c +++ b/NetworkPkg/HttpDxe/HttpProto.c @@ -243,10 +243,12 @@ HttpCloseTcp4ConnCloseEvent ( if (NULL != HttpInstance->ConnToken.CompletionToken.Event) {
gBS->CloseEvent (HttpInstance->ConnToken.CompletionToken.Event);
+ HttpInstance->ConnToken.CompletionToken.Event = NULL;
}
if (NULL != HttpInstance->CloseToken.CompletionToken.Event) {
gBS->CloseEvent(HttpInstance->CloseToken.CompletionToken.Event);
+ HttpInstance->CloseToken.CompletionToken.Event = NULL;
}
}
@@ -581,21 +583,22 @@ HttpCloseConnection ( {
EFI_STATUS Status;
- HttpInstance->CloseToken.AbortOnClose = TRUE;
- HttpInstance->IsCloseDone = FALSE;
-
-
- Status = HttpInstance->Tcp4->Close (HttpInstance->Tcp4, &HttpInstance->CloseToken);
- if (EFI_ERROR (Status)) {
- return Status;
- }
+ if (HttpInstance->State == HTTP_STATE_TCP_CONNECTED) {
+ HttpInstance->CloseToken.AbortOnClose = TRUE;
+ HttpInstance->IsCloseDone = FALSE;
+
+ Status = HttpInstance->Tcp4->Close (HttpInstance->Tcp4, &HttpInstance->CloseToken);
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
- while (!HttpInstance->IsCloseDone) {
- HttpInstance->Tcp4->Poll (HttpInstance->Tcp4);
+ while (!HttpInstance->IsCloseDone) {
+ HttpInstance->Tcp4->Poll (HttpInstance->Tcp4);
+ }
}
HttpInstance->State = HTTP_STATE_TCP_CLOSED;
- return Status;
+ return EFI_SUCCESS;
}
/**
|