From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-in21.apple.com (mail-out21.apple.com [17.171.2.31]) (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 8D78F80431 for ; Fri, 24 Mar 2017 00:08:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; d=apple.com; s=mailout2048s; c=relaxed/simple; q=dns/txt; i=@apple.com; t=1490339324; 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=KNwTFb1Jpme2pJgIipa3cM8g8EsZrS04HuF2ixsrcbo=; b=GtIM+vTssSsOG5leIMHxybz+QTLfDhRo3SfgpS7/xrVBktz3yCcG/rAcUJzlrWMk NmyZcx4pOUc1AgM6hyybpOEE0njEkbvOQbDSynrSYeJ7LQt9tSE+h/7z3a3sKwZR gheUSvS5fajBkGRABhOpInIhnDvyZl6H3wdbsUtFquaHC9C0XKOJqsWXEyqxpXCe zE/T9gRma/5b+WEY17h0kTCyEmiJQpDz7NYNBbeDUYptsCxVUfBRx5Os67DF2TIZ wKn6I1Ks9Ej2MRuo+PzWoSp9XZ25IVZj/29KHBg61F8Cyr2Y0QtbQVFSF6p2ynGn V2uLbo/kdnVzgZc3wCFRUg==; Received: from relay2.apple.com (relay2.apple.com [17.128.113.67]) by mail-in21.apple.com (Apple Secure Mail Relay) with SMTP id 42.D1.24065.AF5C4D85; Fri, 24 Mar 2017 00:08:44 -0700 (PDT) X-AuditID: 11ab0215-9c3fb70000005e01-78-58d4c5fada80 Received: from nwk-mmpp-sz13.apple.com (nwk-mmpp-sz13.apple.com [17.128.115.216]) by relay2.apple.com (Apple SCV relay) with SMTP id 3F.00.06512.9F5C4D85; Fri, 24 Mar 2017 00:08:42 -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 <0ONB00GK156G8H10@nwk-mmpp-sz13.apple.com>; Fri, 24 Mar 2017 00:08:41 -0700 (PDT) Sender: afish@apple.com From: Andrew Fish In-reply-to: Date: Fri, 24 Mar 2017 00:08:40 -0700 Cc: edk2-devel@lists.01.org Message-id: <8F7C944F-352D-4D63-BEB5-59086F05C235@apple.com> References: <9C33D691-C2DF-4F19-933D-5D344B96554B@apple.com> To: Arka Sharma X-Mailer: Apple Mail (2.3226) X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrJLMWRmVeSWpSXmKPExsUi2FDorPvn6JUIgz2zlSw29/SwW+w5dJTZ gclj56y77B7ds/+xBDBFcdmkpOZklqUW6dslcGVMvXiBteAbX8Xb01fYGhjvcXcxcnJICJhI HJy5j7WLkYtDSGAfo8Siad+AHA6wxMsfShDxQ4wSby5dYgdp4BUQlPgx+R4LSA2zgLzEwfOy IGFmAS2J749aWSDqJzJJnN3ziQkkISwgLvHuzCZmkHphAV+Jd8fNQcJsAsoSK+Z/ABvJKRAs sWHjHUYQm0VAVWLnjkYWiJnSEg8nHgc7h1fARmLND0eI8WcYJY70XmAGqRERUJfovzuLEeJk WYnZv7xAaiQE1rBJnJiynm0Co/AsJFfPQrh6FpKrFzAyr2IUzk3MzNHNzDMy1EssKMhJ1UvO z93ECArr1UyiOxjnvzI8xCjAwajEw7uA7XKEEGtiWXFl7iFGaQ4WJXHemSJAIYH0xJLU7NTU gtSi+KLSnNTiQ4xMHJxSDYwrfMVr5qyc1l15IlbTcFVxoeLlhWl86y+ab5jwPDzAt9MmtfvB 8fjvrlXVsbudxXoO/FH48kSywOKi983ltWkavR/1nBmefp2t6hcZmlu2oG6GnJWI2OmHX6be 0lWyNbrME/ngzK/Und9d7384uv2s6KEZE9eISC5iS5UT/a3w/3iOqMva1YlKLMUZiYZazEXF iQB2jdipTAIAAA== X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFupikeLIzCtJLcpLzFFi42IRbCi+ofvr6JUIg+sfeCw29/SwW+w5dJTZ gclj56y77B7ds/+xBDBFcdmkpOZklqUW6dslcGVMvXiBteAbX8Xb01fYGhjvcXcxcnBICJhI vPyh1MXIxSEkcIhR4s2lS+xdjJwcvAKCEj8m32MBqWEWkJc4eF4WJMwsoCXx/VErC0T9RCaJ s3s+MYEkhAXEJd6d2cQMUi8s4Cvx7rg5SJhNQFlixfwPYCM5BYIlNmy8wwhiswioSuzc0cgC MVNa4uHE46wgrbwCNhJrfjhCjD/DKHGk9wIzSI2IgLpE/91ZjBAny0rM/uU1gVFgFpJDZyEc OgvJoQsYmVcxChSl5iRWGuklFhTkpOol5+duYgQHYaHzDsZjy6wOMQpwMCrx8G6ouxQhxJpY VlyZCwwJDmYlEV7RFVcihHhTEiurUovy44tKc1KLDzFWAZ0/kVlKNDkfGCF5JfGGJiYGJsbG ZsbG5ibmVBFWEuft+gJ0jEB6YklqdmpqQWoRzHImDk6pBsZp1yWSGtfuND2/vS7i5lYN1fhT dltFez9tePwz/NOuW09sV236y3NBqpdl5XbHdLbi8jXH1Xi7dSUyNP+m9WxbEb4hWvp3zJRt quXys1e92Kj2jntiWduTX6UbPxxT5MxwfBASXJK6+sIVzkXCees9PptfKm1tzGd3PvafUf7I pR1N8Q1uJ3YpsRRnJBpqMRcVJwIANF287p0CAAA= 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 07:08:45 -0000 Content-transfer-encoding: 7BIT Content-type: text/plain; CHARSET=US-ASCII > On Mar 24, 2017, at 12:07 AM, Arka Sharma wrote: > > Thanks Andrew for your reply. In this case I am creating the event > with CreateEvent() and not with CreateEventEx(). I am attempting to > free the Context inside the notify function which will be called after > Event is signaled, and Context is only accessed before CreateEvent() > and inside the NotifyRoutine(). So the change you are suggesting is > inside the notify function I should call CloseEvent() first before > freeing Context right ? > Yes as your event can get signaled until you close it in the general case. Thanks, Andrew Fish > On Fri, Mar 24, 2017 at 12:07 PM, Andrew Fish wrote: >> >>> 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 >>