If the 2nd boot quickly after the first succeed boot, it will function well.
But if you wait for some time after 1nd succeed boot and boot again, the
TCP state may change from established to closed wait as the http server send
fin flag, then boot fail occurred.
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Zhang Lubo <lubo.zhang@intel.com>
Reviewed-by: Ye Ting <ting.ye@intel.com>
Reviewed-by: Fu Siyuan <siyuan.fu@intel.com>
git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@18783
6f19259b-4bc3-4df7-8a09-
765794883524
if (EFI_ERROR (Status)) {\r
RemotePort = HTTP_DEFAULT_PORT;\r
}\r
if (EFI_ERROR (Status)) {\r
RemotePort = HTTP_DEFAULT_PORT;\r
}\r
+ //\r
+ // If Configure is TRUE, it indicates the first time to call Request();\r
+ // If ReConfigure is TRUE, it indicates the request URL is not same\r
+ // with the previous call to Request();\r
+ //\r
Configure = TRUE;\r
ReConfigure = TRUE; \r
\r
Configure = TRUE;\r
ReConfigure = TRUE; \r
\r
//\r
// The request URL is different from previous calls to Request(), close existing TCP instance.\r
//\r
//\r
// The request URL is different from previous calls to Request(), close existing TCP instance.\r
//\r
- ASSERT (HttpInstance->Tcp4 != NULL &&HttpInstance->Tcp6 != NULL);\r
+ if (!HttpInstance->LocalAddressIsIPv6) {\r
+ ASSERT (HttpInstance->Tcp4 != NULL);\r
+ } else {\r
+ ASSERT (HttpInstance->Tcp6 != NULL);\r
+ }\r
HttpCloseConnection (HttpInstance);\r
EfiHttpCancel (This, NULL);\r
}\r
HttpCloseConnection (HttpInstance);\r
EfiHttpCancel (This, NULL);\r
}\r
Wrap->HttpInstance = HttpInstance;\r
Wrap->TcpWrap.Method = Request->Method;\r
\r
Wrap->HttpInstance = HttpInstance;\r
Wrap->TcpWrap.Method = Request->Method;\r
\r
- if (Configure) {\r
- Status = HttpInitTcp (HttpInstance, Wrap);\r
- if (EFI_ERROR (Status)) {\r
- goto Error2;\r
- }\r
+ Status = HttpInitTcp (HttpInstance, Wrap, Configure);\r
+ if (EFI_ERROR (Status)) {\r
+ goto Error2;\r
+ } \r
//\r
// For the new HTTP token, create TX TCP token events. \r
//\r
//\r
// For the new HTTP token, create TX TCP token events. \r
//\r
//\r
// Create request message.\r
//\r
//\r
// Create request message.\r
//\r
EFI_TCP4_CONNECTION_STATE Tcp4State;\r
\r
\r
EFI_TCP4_CONNECTION_STATE Tcp4State;\r
\r
\r
- if (HttpInstance->State != HTTP_STATE_TCP_CONFIGED || HttpInstance->Tcp4 == NULL) {\r
+ if (HttpInstance->State < HTTP_STATE_TCP_CONFIGED || HttpInstance->Tcp4 == NULL) {\r
return EFI_NOT_READY;\r
}\r
\r
return EFI_NOT_READY;\r
}\r
\r
- if (Tcp4State > Tcp4StateEstablished) {\r
+ if (Tcp4State == Tcp4StateEstablished) {\r
+ return EFI_SUCCESS;\r
+ } else if (Tcp4State > Tcp4StateEstablished ) {\r
HttpCloseConnection(HttpInstance);\r
HttpCloseConnection(HttpInstance);\r
\r
return HttpCreateConnection (HttpInstance);\r
}\r
\r
return HttpCreateConnection (HttpInstance);\r
}\r
EFI_STATUS Status;\r
EFI_TCP6_CONNECTION_STATE Tcp6State;\r
\r
EFI_STATUS Status;\r
EFI_TCP6_CONNECTION_STATE Tcp6State;\r
\r
- if (HttpInstance->State != HTTP_STATE_TCP_CONFIGED || HttpInstance->Tcp6 == NULL) {\r
+ if (HttpInstance->State < HTTP_STATE_TCP_CONFIGED || HttpInstance->Tcp6 == NULL) {\r
return EFI_NOT_READY;\r
}\r
\r
return EFI_NOT_READY;\r
}\r
\r
- if (Tcp6State > Tcp6StateEstablished) {\r
- HttpCloseConnection (HttpInstance);\r
+ if (Tcp6State == Tcp6StateEstablished) {\r
+ return EFI_SUCCESS;\r
+ } else if (Tcp6State > Tcp6StateEstablished ) {\r
+ HttpCloseConnection(HttpInstance);\r
}\r
\r
return HttpCreateConnection (HttpInstance);\r
}\r
\r
return HttpCreateConnection (HttpInstance);\r
\r
@param[in] HttpInstance The HTTP instance private data.\r
@param[in] Wrap The HTTP token's wrap data.\r
\r
@param[in] HttpInstance The HTTP instance private data.\r
@param[in] Wrap The HTTP token's wrap data.\r
+ @param[in] Configure The Flag indicates whether the first time to initialize Tcp.\r
\r
@retval EFI_SUCCESS The initialization of TCP instance is done. \r
@retval Others Other error as indicated.\r
\r
@retval EFI_SUCCESS The initialization of TCP instance is done. \r
@retval Others Other error as indicated.\r
EFI_STATUS\r
HttpInitTcp (\r
IN HTTP_PROTOCOL *HttpInstance,\r
EFI_STATUS\r
HttpInitTcp (\r
IN HTTP_PROTOCOL *HttpInstance,\r
- IN HTTP_TOKEN_WRAP *Wrap\r
+ IN HTTP_TOKEN_WRAP *Wrap,\r
+ IN BOOLEAN Configure\r
)\r
{\r
EFI_STATUS Status;\r
)\r
{\r
EFI_STATUS Status;\r
//\r
// Configure TCP instance.\r
//\r
//\r
// Configure TCP instance.\r
//\r
- Status = HttpConfigureTcp4 (HttpInstance, Wrap);\r
- if (EFI_ERROR (Status)) {\r
- return Status;\r
+ if (Configure) {\r
+ Status = HttpConfigureTcp4 (HttpInstance, Wrap);\r
+ if (EFI_ERROR (Status)) {\r
+ return Status;\r
+ }\r
//\r
// Connect TCP.\r
//\r
//\r
// Connect TCP.\r
//\r
//\r
// Configure TCP instance.\r
//\r
//\r
// Configure TCP instance.\r
//\r
- Status = HttpConfigureTcp6 (HttpInstance, Wrap);\r
- if (EFI_ERROR (Status)) {\r
- return Status;\r
+ if (Configure) {\r
+ Status = HttpConfigureTcp6 (HttpInstance, Wrap);\r
+ if (EFI_ERROR (Status)) {\r
+ return Status;\r
+ }\r
//\r
// Connect TCP.\r
//\r
//\r
// Connect TCP.\r
//\r
\r
@param[in] HttpInstance The HTTP instance private data.\r
@param[in] Wrap The HTTP token's wrap data.\r
\r
@param[in] HttpInstance The HTTP instance private data.\r
@param[in] Wrap The HTTP token's wrap data.\r
+ @param[in] Configure The Flag indicates whether the first time to initialize Tcp.\r
\r
@retval EFI_SUCCESS The initialization of TCP instance is done. \r
@retval Others Other error as indicated.\r
\r
@retval EFI_SUCCESS The initialization of TCP instance is done. \r
@retval Others Other error as indicated.\r
EFI_STATUS\r
HttpInitTcp (\r
IN HTTP_PROTOCOL *HttpInstance,\r
EFI_STATUS\r
HttpInitTcp (\r
IN HTTP_PROTOCOL *HttpInstance,\r
- IN HTTP_TOKEN_WRAP *Wrap\r
+ IN HTTP_TOKEN_WRAP *Wrap,\r
+ IN BOOLEAN Configure\r