From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-in4.apple.com (mail-out4.apple.com [17.151.62.26]) (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 33502802B0 for ; Thu, 23 Mar 2017 23:37:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; d=apple.com; s=mailout2048s; c=relaxed/simple; q=dns/txt; i=@apple.com; t=1490337470; h=From:Sender:Reply-To:Subject:Date:Message-id:To:Cc:MIME-version:Content-type: Content-transfer-encoding:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-reply-to:References:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=33/vvzjK9whGIsopg5DUgxKr6IxCb6jeA+AMgMvXhr8=; b=S5q1A/rOOhcy+yyr+t3dLC9rUsLCrgER7VgFPB+xWv6go10qHtuEZVj6BnRZEh36 aX2TiDJiWKTLQHO9VBIiodxPAh6xAergb4bPO1+cixNYTJonG6Mc4jiLeF4YNcJ2 0iqksjZIz+u3TWssHLIkUW5ayagqUPdL6/BjwE6Vx7DeFmYoAS2enW3ta2xE3nQG 8F9I/mlnLA0ky2uz2h1uVqjtYRitXoO3IVh851jLGiwKSHWAH5OBstEWQ9+Fx6JV 0eYKSwCdh18ss37vnlvzMNSIFIWfNIAamFt5U4GfiPr/PxdbWjIkZQA+xOMyg9AS eFU+Z4HHf0djB0adwAZJBA==; Received: from relay5.apple.com (relay5.apple.com [17.128.113.88]) by mail-in4.apple.com (Apple Secure Mail Relay) with SMTP id BB.54.25383.BBEB4D85; Thu, 23 Mar 2017 23:37:50 -0700 (PDT) X-AuditID: 11973e12-ad7fb70000006327-f0-58d4bebb6156 Received: from nwk-mmpp-sz13.apple.com (nwk-mmpp-sz13.apple.com [17.128.115.216]) by relay5.apple.com (Apple SCV relay) with SMTP id 6C.D3.06491.BBEB4D85; Thu, 23 Mar 2017 23:37:47 -0700 (PDT) MIME-version: 1.0 Received: from [17.153.54.129] (unknown [17.153.54.129]) by nwk-mmpp-sz13.apple.com (Oracle Communications Messaging Server 8.0.1.2.20170210 64bit (built Feb 10 2017)) with ESMTPSA id <0ONB000FQ3QYI480@nwk-mmpp-sz13.apple.com>; Thu, 23 Mar 2017 23:37:47 -0700 (PDT) Sender: afish@apple.com From: Andrew Fish In-reply-to: Date: Thu, 23 Mar 2017 23:37:46 -0700 Cc: edk2-devel@lists.01.org Message-id: <9C33D691-C2DF-4F19-933D-5D344B96554B@apple.com> References: To: Arka Sharma X-Mailer: Apple Mail (2.3226) X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrBLMWRmVeSWpSXmKPExsUi2FAYobtv35UIg7/rTS029/SwW+w5dJTZ gclj56y77B7ds/+xBDBFcdmkpOZklqUW6dslcGVsPjSFpeAsR8XVR1cYGxjPs3UxcnJICJhI TJ+ymb2LkYtDSGAvo8ScLwsZYRK3np5ngkgcYpR4u3gzM0iCV0BQ4sfkeyxdjBwczALyEgfP y4KEmQW0JL4/amWBqJ/IJHH36HGwemEBcYl3ZzYxg9QLC/hKvDtuDhJmE1CWWDH/AzuIzSkQ LHFz/hYmEJtFQFXi7M9T7BAzpSUeTjzOCtLKK2Aj8XVPOUhYSCBA4u/qW2AlIgLqEv13ZzGC lEgIyErM/uUFcoGEwBo2iTt3JrFOYBSeheToWQhHz0Jy9AJG5lWMQrmJmTm6mXkmeokFBTmp esn5uZsYQUE93U5oB+OpVVaHGAU4GJV4eCNqLkUIsSaWFVfmHmKU5mBREufVFrkcISSQnliS mp2aWpBaFF9UmpNafIiRiYNTqoFxvviC51+6i5yk3il+PrppacUy+XVNkrMX7dLQVelwm887 WX9Ksfvyn9FPPr2N1DguHxFvtHsXQ87yYyor12/cp8+98NPeX3PnWq/byF52kSfLQG7jGbdt /k//WVcvi5ny2U1hfuCOe25PT0R3cWgGH23dWv/6zoXWnbyB2hpX+UKZk+KvbZrjqsRSnJFo qMVcVJwIADzt0XdLAgAA X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFupikeLIzCtJLcpLzFFi42IRbCi+obt735UIg0WXLC029/SwW+w5dJTZ gclj56y77B7ds/+xBDBFcdmkpOZklqUW6dslcGVsPjSFpeAsR8XVR1cYGxjPs3UxcnJICJhI 3Hp6nqmLkYtDSOAQo8TbxZuZQRK8AoISPybfY+li5OBgFpCXOHheFiTMLKAl8f1RKwtE/UQm ibtHj4PVCwuIS7w7s4kZpF5YwFfi3XFzkDCbgLLEivkf2EFsToFgiZvztzCB2CwCqhJnf55i h5gpLfFw4nFWkFZeARuJr3vKQcJCAgESf1ffAisREVCX6L87ixGkREJAVmL2L68JjAKzkNw5 C+HOWUjuXMDIvIpRoCg1J7HSVC+xoCAnVS85P3cTIzgICyN2MP5fZnWIUYCDUYmHd0PdpQgh 1sSy4spcYEBwMCuJ8IquuBIhxJuSWFmVWpQfX1Sak1p8iLEK6PqJzFKiyfnACMkriTc0MTEw MTY2MzY2NzGnirCSOG/XF6BjBNITS1KzU1MLUotgljNxcEo1MIYuMdbsu3/+/YIT6ye3V/ff mCMcbb1YsrG59Px2Ox/jogr3kpuKyyaLXO/Va7E72Cx2sC/skvDJFsvbXX0pKYxq80rjg9c7 MG1bfDE0qOrDO4eNGc61dQUF7Zodf733LdolXlQmuYW9vz1ylR33g89zE1Q+XW2Y+UOs/dPN Ywe7n8qtvzstUImlOCPRUIu5qDgRACl5/uadAgAA Subject: Re: Closing events and releasing resources in notify function 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: Fri, 24 Mar 2017 06:37:51 -0000 Content-transfer-encoding: 7BIT Content-type: text/plain; CHARSET=US-ASCII > On Mar 23, 2017, at 11:22 PM, Arka Sharma wrote: > > Hi, > > Is it ok to close the event and release the resource allocated to be > sent as context inside the notify function. May be something like this > > VOID > EFIAPI > NotifyRoutine ( > EFI_EVENT Event, > VOID *Context > ) > { > // > // Perform intended task > // > FreePool (Context); > gBS->CloseEvent (Event); You should close the event before you free the context, or you will have a race. You need to make sure there is no way for EFI to signal the event before you free the context. This all assumes you don't have other code doing crazy stuff with the Context or Event. It would be a different answer for CreateEventEx() Thanks, Andrew Fish > } > > In the above example Context was allocated before creating the event > and passed as a parameter to CreateEvent(). > > Regards, > Arka > _______________________________________________ > edk2-devel mailing list > edk2-devel@lists.01.org > https://lists.01.org/mailman/listinfo/edk2-devel