aboutsummaryrefslogtreecommitdiff
path: root/socket.h
diff options
context:
space:
mode:
authorStefan Hajnoczi <stefanha@redhat.com>2013-02-20 11:28:28 +0100
committerAnthony Liguori <aliguori@us.ibm.com>2013-02-21 16:17:31 -0600
commitfc7626711be9b339157e48f29e54c64f612171cb (patch)
tree84738b08a612e1f1b9a61b6d7f9baa20917b7745 /socket.h
parent1eec66adf65d87e280798f32044e0ab967f8447b (diff)
downloadslirp-fc7626711be9b339157e48f29e54c64f612171cb.zip
slirp-fc7626711be9b339157e48f29e54c64f612171cb.tar.gz
slirp-fc7626711be9b339157e48f29e54c64f612171cb.tar.bz2
slirp: switch to GPollFD
Slirp uses rfds/wfds/xfds more extensively than other QEMU components. The rarely-used out-of-band TCP data feature is used. That means we need the full table of select(2) to g_poll(3) events: rfds -> G_IO_IN | G_IO_HUP | G_IO_ERR wfds -> G_IO_OUT | G_IO_ERR xfds -> G_IO_PRI I came up with this table by looking at Linux fs/select.c which maps select(2) to poll(2) internally. Another detail to watch out for are the global variables that reference rfds/wfds/xfds during slirp_select_poll(). sofcantrcvmore() and sofcantsendmore() use these globals to clear fd_set bits. When sofcantrcvmore() is called, the wfds bit is cleared so that the write handler will no longer be run for this iteration of the event loop. This actually seems buggy to me since TCP connections can be half-closed and we'd still want to handle data in half-duplex fashion. I think the real intention is to avoid running the read/write handler when the socket has been fully closed. This is indicated with the SS_NOFDREF state bit so we now check for it before invoking the TCP write handler. Note that UDP/ICMP code paths don't care because they are connectionless. Note that slirp/ has a lot of tabs and sometimes mixed tabs with spaces. I followed the style of the surrounding code. Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> Reviewed-by: Laszlo Ersek <lersek@redhat.com> Message-id: 1361356113-11049-6-git-send-email-stefanha@redhat.com Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Diffstat (limited to 'socket.h')
-rw-r--r--socket.h2
1 files changed, 2 insertions, 0 deletions
diff --git a/socket.h b/socket.h
index 7f67581..a40aa66 100644
--- a/socket.h
+++ b/socket.h
@@ -20,6 +20,8 @@ struct socket {
int s; /* The actual socket */
+ int pollfds_idx; /* GPollFD GArray index */
+
Slirp *slirp; /* managing slirp instance */
/* XXX union these with not-yet-used sbuf params */