From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:38120) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1S7Kvt-00010U-BN for qemu-devel@nongnu.org; Tue, 13 Mar 2012 02:10:06 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1S7Kvo-00074D-7q for qemu-devel@nongnu.org; Tue, 13 Mar 2012 02:10:04 -0400 Received: from mailout3.w1.samsung.com ([210.118.77.13]:16663) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1S7Kvo-00073s-1Y for qemu-devel@nongnu.org; Tue, 13 Mar 2012 02:10:00 -0400 Received: from euspt1 ([210.118.77.13]) by mailout3.w1.samsung.com (Sun Java(tm) System Messaging Server 6.3-8.04 (built Jul 29 2009; 32bit)) with ESMTP id <0M0T00HFW7SK2A40@mailout3.w1.samsung.com> for qemu-devel@nongnu.org; Tue, 13 Mar 2012 06:09:56 +0000 (GMT) Received: from [106.109.8.162] by spt1.w1.samsung.com (iPlanet Messaging Server 5.2 Patch 2 (built Jul 14 2004)) with ESMTPA id <0M0T00DZW7SJ9K@spt1.w1.samsung.com> for qemu-devel@nongnu.org; Tue, 13 Mar 2012 06:09:56 +0000 (GMT) Date: Tue, 13 Mar 2012 10:09:54 +0400 From: Igor Mitsyanko In-reply-to: <1331557893-30806-4-git-send-email-marcandre.lureau@redhat.com> Message-id: <4F5EE4B2.5040802@samsung.com> MIME-version: 1.0 Content-type: text/plain; charset=ISO-8859-1; format=flowed Content-transfer-encoding: QUOTED-PRINTABLE References: <1331557893-30806-1-git-send-email-marcandre.lureau@redhat.com> <1331557893-30806-4-git-send-email-marcandre.lureau@redhat.com> Subject: Re: [Qemu-devel] [PATCH/RFC 3/7] Close socket when closing QEMUFile Reply-To: i.mitsyanko@samsung.com List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: =?ISO-8859-1?Q?Marc-Andr=E9_Lureau?= Cc: =?ISO-8859-1?Q?Marc-Andr=E9_Lureau?= , qemu-devel@nongnu.org On 03/12/2012 05:11 PM, Marc-Andr=E9 Lureau wrote: > --- > migration-tcp.c | 9 +++++---- > migration-unix.c | 9 +++++---- > savevm.c | 1 + > 3 files changed, 11 insertions(+), 8 deletions(-) > > diff --git a/migration-tcp.c b/migration-tcp.c > index f567898..056867c 100644 > --- a/migration-tcp.c > +++ b/migration-tcp.c > @@ -137,7 +137,7 @@ static void tcp_accept_incoming_migration(void = *opaque) > > if (c =3D=3D -1) { > fprintf(stderr, "could not accept migration connection\n"= ); > - goto out2; > + goto out; > } > > f =3D qemu_fopen_socket(c, "r"); > @@ -145,12 +145,13 @@ static void tcp_accept_incoming_migration(voi= d *opaque) > fprintf(stderr, "could not qemu_fopen socket\n"); > goto out; > } > - > + c =3D -1; > process_incoming_migration(f); > qemu_fclose(f); > + > out: > - close(c); > -out2: > + if (c !=3D -1) > + close(c); > qemu_set_fd_handler2(s, NULL, NULL, NULL, NULL); > close(s); > } > diff --git a/migration-unix.c b/migration-unix.c > index 3928f4c..0a3a076 100644 > --- a/migration-unix.c > +++ b/migration-unix.c > @@ -134,7 +134,7 @@ static void unix_accept_incoming_migration(void= *opaque) > > if (c =3D=3D -1) { > fprintf(stderr, "could not accept migration connection\n"= ); > - goto out2; > + goto out; > } > > f =3D qemu_fopen_socket(c, "r"); > @@ -142,12 +142,13 @@ static void unix_accept_incoming_migration(vo= id *opaque) > fprintf(stderr, "could not qemu_fopen socket\n"); > goto out; > } > - > + c =3D -1; > process_incoming_migration(f); > qemu_fclose(f); > + > out: > - close(c); > -out2: > + if (c !=3D -1) > + close(c); > qemu_set_fd_handler2(s, NULL, NULL, NULL, NULL); > close(s); > } As I understand you want to close(c) only if (f =3D=3D NULL) succeede= d, and=20 do not want to do this in normal function path? It looks strange (I'm= =20 not an expert though), but if this is actually correct, than you can = do=20 this in "if (f =3D=3D NULL)" body, without checking if (c !=3D -1). --=20 Mitsyanko Igor ASWG, Moscow R&D center, Samsung Electronics email: i.mitsyanko@samsung.com