From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:58996) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SdB7c-0001gf-Vq for qemu-devel@nongnu.org; Fri, 08 Jun 2012 22:09:50 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SdB7b-00020q-7q for qemu-devel@nongnu.org; Fri, 08 Jun 2012 22:09:48 -0400 Received: from mail-ob0-f173.google.com ([209.85.214.173]:47387) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SdB7b-00020l-0D for qemu-devel@nongnu.org; Fri, 08 Jun 2012 22:09:47 -0400 Received: by obbwd20 with SMTP id wd20so3518902obb.4 for ; Fri, 08 Jun 2012 19:09:45 -0700 (PDT) MIME-Version: 1.0 In-Reply-To: References: <1339080860-16036-1-git-send-email-zwu.kernel@gmail.com> Date: Sat, 9 Jun 2012 10:09:44 +0800 Message-ID: From: Zhi Yong Wu Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH v5 2/2] net: add the support for -netdev socket, listen List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Stefan Hajnoczi Cc: pbonzini@redhat.com, Zhi Yong Wu , qemu-devel@nongnu.org, stefanha@linux.vnet.ibm.com On Fri, Jun 8, 2012 at 11:59 PM, Stefan Hajnoczi wrote= : > On Fri, Jun 8, 2012 at 3:54 PM, Zhi Yong Wu wrote: >> On Fri, Jun 8, 2012 at 6:31 PM, Stefan Hajnoczi wro= te: >>> On Thu, Jun 7, 2012 at 3:54 PM, =A0 wrote: >>>> @@ -86,7 +82,16 @@ static void net_socket_send(void *opaque) >>>> =A0 =A0 =A0 =A0 /* end of connection */ >>>> =A0 =A0 eoc: >>>> =A0 =A0 =A0 =A0 qemu_set_fd_handler(s->fd, NULL, NULL, NULL); >>>> + =A0 =A0 =A0 =A0qemu_set_fd_handler(s->listen_fd, net_socket_accept, = NULL, s); >>> >>> What happens when this is not a listen socket? =A0I suggest setting >>> listen_fd to -1 during creation and not calling qemu_set_fd_handler() >>> when listen_fd is -1 here. =A0If listen_fd is 0 then we'll register >>> net_socket_accept when standard input becomes ready! >>> >>>> =A0 =A0 =A0 =A0 closesocket(s->fd); >>>> + >>>> + =A0 =A0 =A0 =A0s->fd =3D 0; >>> >>> -1 should be used since 0 is a valid file descriptor (standard input). >> I think that s->fd =3D 0 doesn't cause every issue. When it is zero, >> this fd hasn't been registered with every handler. You can see that >> "qemu_set_fd_handler(s->fd, NULL, NULL, NULL);" before "s->fd =3D 0". > > If s->fd =3D 0 because we are still listening and net_socket_cleanup() OK, done. any other issue? > is called we will close() standard input. > > Stefan --=20 Regards, Zhi Yong Wu