VOID *UrlParser;\r
EFI_STATUS Status;\r
CHAR8 *HostName;\r
+ UINTN HostNameSize;\r
UINT16 RemotePort;\r
HTTP_PROTOCOL *HttpInstance;\r
BOOLEAN Configure;\r
}\r
\r
\r
- UnicodeStrToAsciiStr (Request->Url, Url);\r
+ UnicodeStrToAsciiStrS (Request->Url, Url, UrlLen);\r
UrlParser = NULL;\r
Status = HttpParseUrl (Url, (UINT32) AsciiStrLen (Url), FALSE, &UrlParser);\r
if (EFI_ERROR (Status)) {\r
}\r
\r
if (EFI_ERROR (Status)) {\r
- HostNameStr = AllocateZeroPool ((AsciiStrLen (HostName) + 1) * sizeof (CHAR16));\r
+ HostNameSize = AsciiStrSize (HostName);\r
+ HostNameStr = AllocateZeroPool (HostNameSize * sizeof (CHAR16));\r
if (HostNameStr == NULL) {\r
Status = EFI_OUT_OF_RESOURCES;\r
goto Error1;\r
}\r
\r
- AsciiStrToUnicodeStr (HostName, HostNameStr);\r
+ AsciiStrToUnicodeStrS (HostName, HostNameStr, HostNameSize);\r
if (!HttpInstance->LocalAddressIsIPv6) {\r
Status = HttpDns4 (HttpInstance, HostNameStr, &HttpInstance->RemoteAddr);\r
} else {\r
}\r
}\r
\r
-\r
//\r
// Save the RemotePort and RemoteHost.\r
//\r
return EFI_SUCCESS;\r
\r
Error5:\r
- //\r
- // We would have inserted a TxToken only if Request structure is not NULL.\r
- // Hence check before we do a remove in this error case.\r
- //\r
- if (Request != NULL) {\r
- NetMapRemoveTail (&HttpInstance->TxTokens, NULL);\r
- }\r
+ //\r
+ // We would have inserted a TxToken only if Request structure is not NULL.\r
+ // Hence check before we do a remove in this error case.\r
+ //\r
+ if (Request != NULL) {\r
+ NetMapRemoveTail (&HttpInstance->TxTokens, NULL);\r
+ }\r
\r
Error4:\r
if (RequestMsg != NULL) {\r
}\r
\r
Error1:\r
-\r
if (HostName != NULL) {\r
FreePool (HostName);\r
}\r
IN VOID *Context\r
)\r
{\r
-\r
EFI_HTTP_TOKEN *Token;\r
HTTP_TOKEN_WRAP *Wrap;\r
HTTP_PROTOCOL *HttpInstance;\r
Wrap = (HTTP_TOKEN_WRAP *) Item->Value;\r
ASSERT (Wrap != NULL);\r
HttpInstance = Wrap->HttpInstance;\r
-\r
- //\r
- // Free resources.\r
- //\r
- NetMapRemoveItem (Map, Item, NULL); \r
\r
if (!HttpInstance->LocalAddressIsIPv6) {\r
- if (Wrap->TcpWrap.Tx4Token.CompletionToken.Event != NULL) {\r
- gBS->CloseEvent (Wrap->TcpWrap.Tx4Token.CompletionToken.Event);\r
- }\r
- \r
if (Wrap->TcpWrap.Rx4Token.CompletionToken.Event != NULL) {\r
- gBS->CloseEvent (Wrap->TcpWrap.Rx4Token.CompletionToken.Event);\r
- }\r
- \r
- if (Wrap->TcpWrap.Rx4Token.Packet.RxData->FragmentTable[0].FragmentBuffer != NULL) {\r
- FreePool (Wrap->TcpWrap.Rx4Token.Packet.RxData->FragmentTable[0].FragmentBuffer);\r
- }\r
+ //\r
+ // Cancle the Token before close its Event.\r
+ //\r
+ HttpInstance->Tcp4->Cancel (HttpInstance->Tcp4, &Wrap->TcpWrap.Rx4Token.CompletionToken);\r
\r
- } else {\r
- if (Wrap->TcpWrap.Tx6Token.CompletionToken.Event != NULL) {\r
- gBS->CloseEvent (Wrap->TcpWrap.Tx6Token.CompletionToken.Event);\r
+ //\r
+ // Dispatch the DPC queued by the NotifyFunction of the canceled token's events.\r
+ //\r
+ DispatchDpc ();\r
}\r
-\r
+ } else {\r
if (Wrap->TcpWrap.Rx6Token.CompletionToken.Event != NULL) {\r
- gBS->CloseEvent (Wrap->TcpWrap.Rx6Token.CompletionToken.Event);\r
- }\r
+ //\r
+ // Cancle the Token before close its Event.\r
+ //\r
+ HttpInstance->Tcp6->Cancel (HttpInstance->Tcp6, &Wrap->TcpWrap.Rx6Token.CompletionToken);\r
\r
- if (Wrap->TcpWrap.Rx6Token.Packet.RxData->FragmentTable[0].FragmentBuffer != NULL) {\r
- FreePool (Wrap->TcpWrap.Rx6Token.Packet.RxData->FragmentTable[0].FragmentBuffer);\r
+ //\r
+ // Dispatch the DPC queued by the NotifyFunction of the canceled token's events.\r
+ //\r
+ DispatchDpc ();\r
}\r
}\r
\r
-\r
- FreePool (Wrap);\r
-\r
//\r
// If only one item is to be cancel, return EFI_ABORTED to stop\r
// iterating the map any more.\r
//\r
StatusCodeStr = HttpHeaders + AsciiStrLen (HTTP_VERSION_STR) + 1;\r
if (StatusCodeStr == NULL) {\r
+ Status = EFI_NOT_READY;\r
goto Error;\r
}\r
\r
//\r
Tmp = AsciiStrStr (HttpHeaders, HTTP_CRLF_STR);\r
if (Tmp == NULL) {\r
+ Status = EFI_NOT_READY;\r
goto Error;\r
}\r
\r
if (SizeofHeaders != 0) {\r
HeaderTmp = AllocateZeroPool (SizeofHeaders);\r
if (HeaderTmp == NULL) {\r
+ Status = EFI_OUT_OF_RESOURCES;\r
goto Error2;\r
}\r
\r
\r
ASSERT (HttpInstance->MsgParser != NULL);\r
\r
- if (HttpInstance->TimeoutEvent == NULL) {\r
- //\r
- // Create TimeoutEvent for response\r
- //\r
- Status = gBS->CreateEvent (\r
- EVT_TIMER,\r
- TPL_CALLBACK,\r
- NULL,\r
- NULL,\r
- &HttpInstance->TimeoutEvent\r
- );\r
- if (EFI_ERROR (Status)) {\r
- goto Error2;\r
- }\r
- }\r
-\r
- //\r
- // Start the timer, and wait Timeout seconds to receive the body packet.\r
- //\r
- Status = gBS->SetTimer (HttpInstance->TimeoutEvent, TimerRelative, HTTP_RESPONSE_TIMEOUT * TICKS_PER_SECOND);\r
- if (EFI_ERROR (Status)) {\r
- goto Error2;\r
- }\r
-\r
//\r
// We still need receive more data when there is no cache data and MsgParser is not NULL;\r
//\r
- Status = HttpTcpReceiveBody (Wrap, HttpMsg, HttpInstance->TimeoutEvent);\r
-\r
- gBS->SetTimer (HttpInstance->TimeoutEvent, TimerCancel, 0);\r
-\r
+ Status = HttpTcpReceiveBody (Wrap, HttpMsg);\r
if (EFI_ERROR (Status)) {\r
goto Error2;\r
}\r
\r
- FreePool (Wrap);\r
return Status;\r
\r
Exit:\r
}\r
\r
Error:\r
+ Item = NetMapFindKey (&Wrap->HttpInstance->RxTokens, Wrap->HttpToken);\r
+ if (Item != NULL) {\r
+ NetMapRemoveItem (&Wrap->HttpInstance->RxTokens, Item, NULL);\r
+ }\r
+ \r
HttpTcpTokenCleanup (Wrap);\r
\r
if (HttpHeaders != NULL) {\r