This patch updates the HTTP driver to use a shared buffer for URL parsing to
avoid memory allocation for each HTTP request.
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Fu Siyuan <siyuan.fu@intel.com>
Reviewed-by: Ye Ting <ting.ye@intel.com>
git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@18449
6f19259b-4bc3-4df7-8a09-
765794883524
BOOLEAN ReConfigure;\r
CHAR8 *RequestStr;\r
CHAR8 *Url;\r
+ UINTN UrlLen;\r
CHAR16 *HostNameStr;\r
HTTP_TOKEN_WRAP *Wrap;\r
HTTP_TCP_TOKEN_WRAP *TcpWrap;\r
//\r
// Parse the URI of the remote host.\r
//\r
- Url = AllocatePool (StrLen (Request->Url) + 1);\r
- if (Url == NULL) {\r
- return EFI_OUT_OF_RESOURCES;\r
- }\r
+ UrlLen = StrLen (Request->Url) + 1;\r
+ if (UrlLen > HTTP_URL_BUFFER_LEN) {\r
+ Url = AllocateZeroPool (UrlLen);\r
+ if (Url == NULL) {\r
+ return EFI_OUT_OF_RESOURCES;\r
+ }\r
+ FreePool (HttpInstance->Url);\r
+ HttpInstance->Url = Url; \r
+ } \r
\r
UnicodeStrToAsciiStr (Request->Url, Url);\r
UrlParser = NULL;\r
\r
Wrap->TcpWrap.Method = Request->Method;\r
\r
- FreePool (Url);\r
FreePool (HostName);\r
\r
//\r
goto Error4;\r
}\r
\r
- FreePool (Url);\r
if (HostName != NULL) {\r
FreePool (HostName);\r
}\r
}\r
\r
Error1:\r
- if (Url != NULL) {\r
- FreePool (Url);\r
- }\r
if (HostName != NULL) {\r
FreePool (HostName);\r
}\r
goto ON_ERROR;\r
}\r
\r
+ HttpInstance->Url = AllocateZeroPool (HTTP_URL_BUFFER_LEN);\r
+ if (HttpInstance->Url == NULL) {\r
+ Status = EFI_OUT_OF_RESOURCES;\r
+ goto ON_ERROR;\r
+ }\r
+\r
NetMapInit (&HttpInstance->TxTokens);\r
NetMapInit (&HttpInstance->RxTokens);\r
\r
HttpInstance->MsgParser = NULL;\r
}\r
\r
+ if (HttpInstance->Url != NULL) {\r
+ FreePool (HttpInstance->Url);\r
+ HttpInstance->Url = NULL;\r
+ }\r
+\r
NetMapClean (&HttpInstance->TxTokens);\r
NetMapClean (&HttpInstance->RxTokens);\r
\r
#define HTTP_KEEP_ALIVE_TIME 7200\r
#define HTTP_KEEP_ALIVE_INTERVAL 30\r
\r
+#define HTTP_URL_BUFFER_LEN 4096\r
+\r
typedef struct _HTTP_SERVICE {\r
UINT32 Signature;\r
EFI_SERVICE_BINDING_PROTOCOL ServiceBinding;\r
\r
NET_MAP TxTokens;\r
NET_MAP RxTokens;\r
+\r
+ CHAR8 *Url;\r
} HTTP_PROTOCOL;\r
\r
typedef struct {\r