From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:54397) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Sd03e-0005fa-6S for qemu-devel@nongnu.org; Fri, 08 Jun 2012 10:20:59 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Sd03c-0005LW-DZ for qemu-devel@nongnu.org; Fri, 08 Jun 2012 10:20:57 -0400 Received: from mail-lb0-f173.google.com ([209.85.217.173]:58890) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Sd03c-0005Fu-1i for qemu-devel@nongnu.org; Fri, 08 Jun 2012 10:20:56 -0400 Received: by lbok6 with SMTP id k6so1581901lbo.4 for ; Fri, 08 Jun 2012 07:20:53 -0700 (PDT) MIME-Version: 1.0 In-Reply-To: References: <1339080860-16036-1-git-send-email-zwu.kernel@gmail.com> Date: Fri, 8 Jun 2012 15:20:53 +0100 Message-ID: From: Stefan Hajnoczi 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: Zhi Yong Wu Cc: pbonzini@redhat.com, Zhi Yong Wu , qemu-devel@nongnu.org, stefanha@linux.vnet.ibm.com On Fri, Jun 8, 2012 at 3:15 PM, Zhi Yong Wu wrote: > On Fri, Jun 8, 2012 at 6:31 PM, Stefan Hajnoczi wrot= e: >> 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, N= ULL, 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() > listen_fd isn't -1 here, and is one valid value when this function is exe= cuted. >> 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). > OK. done, but In fact, some other places default fd to zero. Where? Maybe those places need to be fixed too. The danger with fd=3D0 is that we call functions like read()/write()/close() on standard input by mistake. Stefan