[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [RFC][PATCH v3 06/21] virtproxy: add accept handler for com
From: |
Michael Roth |
Subject: |
[Qemu-devel] [RFC][PATCH v3 06/21] virtproxy: add accept handler for communication channel |
Date: |
Mon, 15 Nov 2010 19:16:00 -0600 |
This accept()'s connections to the socket we told virtproxy to listen
for the channel connection on and sets the appropriate read handler for
the resulting FD. This is only used only for network-based channels and
will most likely be dropped with the introduction of the virtproxy
chardev.
Signed-off-by: Michael Roth <address@hidden>
---
virtproxy.c | 37 +++++++++++++++++++++++++++++++++++++
1 files changed, 37 insertions(+), 0 deletions(-)
diff --git a/virtproxy.c b/virtproxy.c
index edca62e..770b57b 100644
--- a/virtproxy.c
+++ b/virtproxy.c
@@ -199,6 +199,8 @@ static VPConn *get_conn(const VPDriver *drv, int fd, bool
client)
return NULL;
}
+static void vp_channel_accept(void *opaque);
+
/* get VPOForward by service_id */
static VPOForward *get_oforward(const VPDriver *drv, const char *service_id)
{
@@ -226,3 +228,38 @@ static VPIForward *get_iforward(const VPDriver *drv, const
char *service_id)
return NULL;
}
+
+/* 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);
+}
--
1.7.0.4
- Re: [Qemu-devel] [RFC][PATCH v3 03/21] virtproxy: add debug functions for virtproxy core, (continued)
[Qemu-devel] [RFC][PATCH v3 04/21] virtproxy: list look-up functions conns/oforwards/iforwards, Michael Roth, 2010/11/15
[Qemu-devel] [RFC][PATCH v3 02/21] virtproxy: qemu-vp, standalone daemon skeleton, Michael Roth, 2010/11/15
[Qemu-devel] [RFC][PATCH v3 05/21] virtproxy, add vp_channel_send_all, Michael Roth, 2010/11/15
[Qemu-devel] [RFC][PATCH v3 06/21] virtproxy: add accept handler for communication channel,
Michael Roth <=
[Qemu-devel] [RFC][PATCH v3 07/21] virtproxy: add read handler for communication channel, Michael Roth, 2010/11/15
[Qemu-devel] [RFC][PATCH v3 08/21] virtproxy: add vp_new() VPDriver constructor, Michael Roth, 2010/11/15
[Qemu-devel] [RFC][PATCH v3 09/21] virtproxy: interfaces to set/remove/handle VPOForwards, Michael Roth, 2010/11/15
[Qemu-devel] [RFC][PATCH v3 10/21] virtproxy: add handler for data packets, Michael Roth, 2010/11/15
[Qemu-devel] [RFC][PATCH v3 12/21] virtproxy: add vp_handle_packet(), Michael Roth, 2010/11/15
[Qemu-devel] [RFC][PATCH v3 13/21] virtproxy: interfaces to set/remove VPIForwards, Michael Roth, 2010/11/15