From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from [140.186.70.92] (port=53721 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PDonc-0002Ha-U5 for qemu-devel@nongnu.org; Wed, 03 Nov 2010 21:39:40 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PDmLX-0007aO-Iz for qemu-devel@nongnu.org; Wed, 03 Nov 2010 19:02:25 -0400 Received: from e33.co.us.ibm.com ([32.97.110.151]:50910) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PDmLX-0007aG-8R for qemu-devel@nongnu.org; Wed, 03 Nov 2010 19:02:23 -0400 Received: from d03relay05.boulder.ibm.com (d03relay05.boulder.ibm.com [9.17.195.107]) by e33.co.us.ibm.com (8.14.4/8.13.1) with ESMTP id oA3MuoRw017248 for ; Wed, 3 Nov 2010 16:56:50 -0600 Received: from d03av02.boulder.ibm.com (d03av02.boulder.ibm.com [9.17.195.168]) by d03relay05.boulder.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id oA3N2DPU129740 for ; Wed, 3 Nov 2010 17:02:16 -0600 Received: from d03av02.boulder.ibm.com (loopback [127.0.0.1]) by d03av02.boulder.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id oA3N2Cm0024212 for ; Wed, 3 Nov 2010 17:02:13 -0600 From: Adam Litke In-Reply-To: <1288798090-7127-6-git-send-email-mdroth@linux.vnet.ibm.com> References: <1288798090-7127-1-git-send-email-mdroth@linux.vnet.ibm.com> <1288798090-7127-6-git-send-email-mdroth@linux.vnet.ibm.com> Content-Type: text/plain; charset="UTF-8" Date: Wed, 03 Nov 2010 18:02:09 -0500 Message-ID: <1288825329.2846.29.camel@aglitke> Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [Qemu-devel] Re: [RFC][RESEND][PATCH v1 05/15] virtproxy: add accept handler for communication channel List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Michael Roth Cc: abeekhof@redhat.com, agl@linux.vnet.ibm.com, qemu-devel@nongnu.org, aliguori@linux.vnet.ibm.com On Wed, 2010-11-03 at 10:28 -0500, Michael Roth wrote: > This accept()'s connections to the socket we told virt-proxy to listen > for the channel connection on and sets the appropriate read handler for > the resulting FD. > > Signed-off-by: Michael Roth > --- > virtproxy.c | 37 +++++++++++++++++++++++++++++++++++++ > 1 files changed, 37 insertions(+), 0 deletions(-) > > diff --git a/virtproxy.c b/virtproxy.c > index fa17722..20532c2 100644 > --- a/virtproxy.c > +++ b/virtproxy.c > @@ -166,6 +166,8 @@ static VPConn *get_conn(const VPDriver *drv, int fd, bool client) > return NULL; > } > > +static void vp_channel_accept(void *opaque); > + Why the forward declaration? Can you move the function to a different place in the file to avoid this? > +/* accept handler for communication channel > + * > + * accept()s connection to communication channel (for sockets), and sets > + * up the read handler for resulting FD. > + */ > +static void vp_channel_accept(void *opaque) > +{ > + VPDriver *drv = opaque; > + struct sockaddr_in saddr; > + struct sockaddr *addr; > + socklen_t len; > + int fd; > + > + TRACE("called with opaque: %p", drv); > + > + for(;;) { > + len = sizeof(saddr); > + addr = (struct sockaddr *)&saddr; > + fd = qemu_accept(drv->listen_fd, addr, &len); > + > + if (fd < 0 && errno != EINTR) { > + TRACE("accept() failed"); > + return; > + } else if (fd >= 0) { > + TRACE("accepted connection"); > + break; > + } > + } > + > + drv->channel_fd = fd; > + vp_set_fd_handler(drv->channel_fd, vp_channel_read, NULL, drv); > + /* dont accept anymore connections until channel_fd is closed */ > + vp_set_fd_handler(drv->listen_fd, NULL, NULL, NULL); > +} -- Thanks, Adam