From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:56117) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ROE4N-0002S5-KL for qemu-devel@nongnu.org; Wed, 09 Nov 2011 14:44:24 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ROE4M-0000XK-Fm for qemu-devel@nongnu.org; Wed, 09 Nov 2011 14:44:23 -0500 Received: from e7.ny.us.ibm.com ([32.97.182.137]:55933) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ROE4M-0000XD-8p for qemu-devel@nongnu.org; Wed, 09 Nov 2011 14:44:22 -0500 Received: from /spool/local by e7.ny.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 9 Nov 2011 14:44:20 -0500 Received: from d01av02.pok.ibm.com (d01av02.pok.ibm.com [9.56.224.216]) by d01relay01.pok.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id pA9JiIFL082788 for ; Wed, 9 Nov 2011 14:44:18 -0500 Received: from d01av02.pok.ibm.com (loopback [127.0.0.1]) by d01av02.pok.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id pA9JiIIP001508 for ; Wed, 9 Nov 2011 17:44:18 -0200 Message-ID: <4EBAD80E.7000907@us.ibm.com> Date: Wed, 09 Nov 2011 13:44:14 -0600 From: Anthony Liguori MIME-Version: 1.0 References: <1320676574-19251-1-git-send-email-chouteau@adacore.com> In-Reply-To: <1320676574-19251-1-git-send-email-chouteau@adacore.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH 1.0] Replace WriteFileEx with WriteFile in qemu_create_pidfile List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Fabien Chouteau Cc: blauwirbel@gmail.com, weil@mail.berlios.de, pbonzini@redhat.com, qemu-devel@nongnu.org, jan.kiszka@siemens.com On 11/07/2011 08:36 AM, Fabien Chouteau wrote: > The function that writes pidfile for win32 uses WriteFileEx which is an > asynchronous IO function. The arguments given to WriteFileEx are allocated on > the stack and one of them is "in out". When the IO operation is actually > executed the calling function has already returned, so the arguments are no > longer allocated or allocated to another frame. > > Signed-off-by: Fabien Chouteau Applied. Thanks. Regards, Anthony Liguori > --- > os-win32.c | 7 ++++--- > 1 files changed, 4 insertions(+), 3 deletions(-) > > diff --git a/os-win32.c b/os-win32.c > index 7909401..8ad5fa1 100644 > --- a/os-win32.c > +++ b/os-win32.c > @@ -130,14 +130,15 @@ int qemu_create_pidfile(const char *filename) > memset(&overlap, 0, sizeof(overlap)); > > file = CreateFile(filename, GENERIC_WRITE, FILE_SHARE_READ, NULL, > - OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); > + OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); > > if (file == INVALID_HANDLE_VALUE) { > return -1; > } > len = snprintf(buffer, sizeof(buffer), "%d\n", getpid()); > - ret = WriteFileEx(file, (LPCVOID)buffer, (DWORD)len, > - &overlap, NULL); > + ret = WriteFile(file, (LPCVOID)buffer, (DWORD)len, > + NULL,&overlap); > + CloseHandle(file); > if (ret == 0) { > return -1; > }