From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Permerror (SPF Permanent Error: More than 10 MX records returned) identity=mailfrom; client-ip=192.55.52.93; helo=mga11.intel.com; envelope-from=jiaxin.wu@intel.com; receiver=edk2-devel@lists.01.org Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 16EEC20945B6A for ; Mon, 11 Dec 2017 22:17:37 -0800 (PST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 11 Dec 2017 22:22:15 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.45,394,1508828400"; d="scan'208";a="12691107" Received: from fmsmsx104.amr.corp.intel.com ([10.18.124.202]) by fmsmga001.fm.intel.com with ESMTP; 11 Dec 2017 22:22:15 -0800 Received: from fmsmsx156.amr.corp.intel.com (10.18.116.74) by fmsmsx104.amr.corp.intel.com (10.18.124.202) with Microsoft SMTP Server (TLS) id 14.3.319.2; Mon, 11 Dec 2017 22:22:15 -0800 Received: from shsmsx152.ccr.corp.intel.com (10.239.6.52) by fmsmsx156.amr.corp.intel.com (10.18.116.74) with Microsoft SMTP Server (TLS) id 14.3.319.2; Mon, 11 Dec 2017 22:22:14 -0800 Received: from shsmsx103.ccr.corp.intel.com ([169.254.4.213]) by SHSMSX152.ccr.corp.intel.com ([169.254.6.93]) with mapi id 14.03.0319.002; Tue, 12 Dec 2017 14:22:12 +0800 From: "Wu, Jiaxin" To: "Fu, Siyuan" , "edk2-devel@lists.01.org" CC: "Ye, Ting" Thread-Topic: [Patch] MdeModulePkg/TcpIoLib: Check input Timeout before calling CheckEvent() service. Thread-Index: AQHTbZLq09F97ouoX0OezTzfZdgoDqM/R8Yw Date: Tue, 12 Dec 2017 06:22:12 +0000 Message-ID: <895558F6EA4E3B41AC93A00D163B7274163529CC@SHSMSX103.ccr.corp.intel.com> References: <20171205063255.6652-1-siyuan.fu@intel.com> In-Reply-To: <20171205063255.6652-1-siyuan.fu@intel.com> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiN2ZmZDY4ZjctZTJiMy00MTFjLTliYWItYTIxNjE1NjdhNjIyIiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX0lDIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE2LjUuOS4zIiwiVHJ1c3RlZExhYmVsSGFzaCI6IjR0Vm1FVGg0czdQMFl5b1RVSlhGOThTV2crRTJubENCUmRCeDV2bExwQzg9In0= x-ctpclassification: CTP_IC dlp-product: dlpe-windows dlp-version: 11.0.0.116 dlp-reaction: no-action x-originating-ip: [10.239.127.40] MIME-Version: 1.0 Subject: Re: [Patch] MdeModulePkg/TcpIoLib: Check input Timeout before calling CheckEvent() service. X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 12 Dec 2017 06:17:38 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Reviewed-by: Wu Jiaxin > -----Original Message----- > From: Fu Siyuan [mailto:siyuan.fu@intel.com] > Sent: Tuesday, December 5, 2017 2:33 PM > To: edk2-devel@lists.01.org > Cc: Wu, Jiaxin ; Ye, Ting > Subject: [Patch] MdeModulePkg/TcpIoLib: Check input Timeout before > calling CheckEvent() service. >=20 > For TcpIoConnect() and TcpIoAccept(), this patch adds the check for Timeo= ut > event > before calling CheckEvent() service so as to avoid the unnecessary functi= on > call. >=20 > Contributed-under: TianoCore Contribution Agreement 1.0 > Signed-off-by: Fu Siyuan > Cc: Wu Jiaxin > Cc: Ye Ting > --- > MdeModulePkg/Include/Library/TcpIoLib.h | 14 +++++++------- > MdeModulePkg/Library/DxeTcpIoLib/DxeTcpIoLib.c | 20 ++++++++++-------- > -- > 2 files changed, 17 insertions(+), 17 deletions(-) >=20 > diff --git a/MdeModulePkg/Include/Library/TcpIoLib.h > b/MdeModulePkg/Include/Library/TcpIoLib.h > index 2871f6747e..22629dbcd5 100644 > --- a/MdeModulePkg/Include/Library/TcpIoLib.h > +++ b/MdeModulePkg/Include/Library/TcpIoLib.h > @@ -2,7 +2,7 @@ > This library is used to share code between UEFI network stack modules. > It provides the helper routines to access TCP service. >=20 > -Copyright (c) 2010 - 2011, Intel Corporation. All rights reserved.
> +Copyright (c) 2010 - 2017, Intel Corporation. All rights reserved.
> This program and the accompanying materials > are licensed and made available under the terms and conditions of the BS= D > License > which accompanies this distribution. The full text of the license may b= e > found at
> @@ -144,7 +144,7 @@ TcpIoDestroySocket ( > Connect to the other endpoint of the TCP socket. >=20 > @param[in, out] TcpIo The TcpIo wrapping the TCP socket. > - @param[in] Timeout The time to wait for connection done. > + @param[in] Timeout The time to wait for connection done. Set t= o > NULL for infinite wait. >=20 > @retval EFI_SUCCESS Connect to the other endpoint of the TC= P > socket > successfully. > @@ -160,14 +160,14 @@ EFI_STATUS > EFIAPI > TcpIoConnect ( > IN OUT TCP_IO *TcpIo, > - IN EFI_EVENT Timeout > + IN EFI_EVENT Timeout OPTIONAL > ); >=20 > /** > Accept the incomding request from the other endpoint of the TCP socket= . >=20 > @param[in, out] TcpIo The TcpIo wrapping the TCP socket. > - @param[in] Timeout The time to wait for connection done. > + @param[in] Timeout The time to wait for connection done. Set t= o > NULL for infinite wait. >=20 >=20 > @retval EFI_SUCCESS Connect to the other endpoint of the TC= P > socket > @@ -185,7 +185,7 @@ EFI_STATUS > EFIAPI > TcpIoAccept ( > IN OUT TCP_IO *TcpIo, > - IN EFI_EVENT Timeout > + IN EFI_EVENT Timeout OPTIONAL > ); >=20 > /** > @@ -229,7 +229,7 @@ TcpIoTransmit ( > @param[in] Packet The buffer to hold the data copy from the= socket > rx buffer. > @param[in] AsyncMode Is this receive asyncronous or not. > @param[in] Timeout The time to wait for receiving the amount= of data > the Packet > - can hold. > + can hold. Set to NULL for infinite wait. >=20 > @retval EFI_SUCCESS The required amount of data is received= from > the socket. > @retval EFI_INVALID_PARAMETER One or more parameters are invalid. > @@ -246,7 +246,7 @@ TcpIoReceive ( > IN OUT TCP_IO *TcpIo, > IN NET_BUF *Packet, > IN BOOLEAN AsyncMode, > - IN EFI_EVENT Timeout > + IN EFI_EVENT Timeout OPTIONAL > ); >=20 > #endif > diff --git a/MdeModulePkg/Library/DxeTcpIoLib/DxeTcpIoLib.c > b/MdeModulePkg/Library/DxeTcpIoLib/DxeTcpIoLib.c > index 17183e1a6c..a7637579f2 100644 > --- a/MdeModulePkg/Library/DxeTcpIoLib/DxeTcpIoLib.c > +++ b/MdeModulePkg/Library/DxeTcpIoLib/DxeTcpIoLib.c > @@ -2,7 +2,7 @@ > This library is used to share code between UEFI network stack modules. > It provides the helper routines to access TCP service. >=20 > -Copyright (c) 2010 - 2011, Intel Corporation. All rights reserved.
> +Copyright (c) 2010 - 2017, Intel Corporation. All rights reserved.
> This program and the accompanying materials > are licensed and made available under the terms and conditions of the BS= D > License > which accompanies this distribution. The full text of the license may b= e > found at
> @@ -530,7 +530,7 @@ TcpIoDestroySocket ( > Connect to the other endpoint of the TCP socket. >=20 > @param[in, out] TcpIo The TcpIo wrapping the TCP socket. > - @param[in] Timeout The time to wait for connection done. > + @param[in] Timeout The time to wait for connection done. Set t= o > NULL for infinite wait. >=20 > @retval EFI_SUCCESS Connect to the other endpoint of the TC= P > socket > successfully. > @@ -546,7 +546,7 @@ EFI_STATUS > EFIAPI > TcpIoConnect ( > IN OUT TCP_IO *TcpIo, > - IN EFI_EVENT Timeout > + IN EFI_EVENT Timeout OPTIONAL > ) > { > EFI_TCP4_PROTOCOL *Tcp4; > @@ -576,7 +576,7 @@ TcpIoConnect ( > return Status; > } >=20 > - while (!TcpIo->IsConnDone && EFI_ERROR (gBS->CheckEvent (Timeout))) { > + while (!TcpIo->IsConnDone && ((Timeout =3D=3D NULL) || EFI_ERROR (gBS- > >CheckEvent (Timeout)))) { > if (TcpIo->TcpVersion =3D=3D TCP_VERSION_4) { > Tcp4->Poll (Tcp4); > } else { > @@ -597,7 +597,7 @@ TcpIoConnect ( > Accept the incomding request from the other endpoint of the TCP socket= . >=20 > @param[in, out] TcpIo The TcpIo wrapping the TCP socket. > - @param[in] Timeout The time to wait for connection done. > + @param[in] Timeout The time to wait for connection done. Set t= o > NULL for infinite wait. >=20 >=20 > @retval EFI_SUCCESS Connect to the other endpoint of the TC= P > socket > @@ -607,7 +607,7 @@ TcpIoConnect ( > supported in the implementation. >=20 > @retval EFI_TIMEOUT Failed to connect to the other endpoint= of the > - TCP socket in the specified time period= . > + TCP socket in the specified time period= . > @retval Others Other errors as indicated. >=20 > **/ > @@ -615,7 +615,7 @@ EFI_STATUS > EFIAPI > TcpIoAccept ( > IN OUT TCP_IO *TcpIo, > - IN EFI_EVENT Timeout > + IN EFI_EVENT Timeout OPTIONAL > ) > { > EFI_STATUS Status; > @@ -646,7 +646,7 @@ TcpIoAccept ( > return Status; > } >=20 > - while (!TcpIo->IsListenDone && EFI_ERROR (gBS->CheckEvent (Timeout))) > { > + while (!TcpIo->IsListenDone && ((Timeout =3D=3D NULL) || EFI_ERROR (gB= S- > >CheckEvent (Timeout)))) { > if (TcpIo->TcpVersion =3D=3D TCP_VERSION_4) { > Tcp4->Poll (Tcp4); > } else { > @@ -860,7 +860,7 @@ ON_EXIT: > @param[in] Packet The buffer to hold the data copy from the= socket > rx buffer. > @param[in] AsyncMode Is this receive asyncronous or not. > @param[in] Timeout The time to wait for receiving the amount= of data > the Packet > - can hold. > + can hold. Set to NULL for infinite wait. >=20 > @retval EFI_SUCCESS The required amount of data is received= from > the socket. > @retval EFI_INVALID_PARAMETER One or more parameters are invalid. > @@ -877,7 +877,7 @@ TcpIoReceive ( > IN OUT TCP_IO *TcpIo, > IN NET_BUF *Packet, > IN BOOLEAN AsyncMode, > - IN EFI_EVENT Timeout > + IN EFI_EVENT Timeout OPTIONAL > ) > { > EFI_TCP4_PROTOCOL *Tcp4; > -- > 2.13.0.windows.1