qemu-e2k/slirp
Stefan Hajnoczi 8917c3bdba 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>
2013-02-21 16:17:31 -06:00
..
arp_table.c slirp: Don't crash on packets from 0.0.0.0/8. 2012-11-15 10:27:14 +01:00
bootp.c slirp: Add domain-search option to slirp's DHCP server 2012-11-15 10:27:14 +01:00
bootp.h janitor: add guards to headers 2012-12-19 08:31:31 +01:00
cksum.c
COPYRIGHT
debug.h
dnssearch.c slirp: Add domain-search option to slirp's DHCP server 2012-11-15 10:27:14 +01:00
if.c misc: move include files to include/qemu/ 2012-12-19 08:32:39 +01:00
if.h
ip_icmp.c Fix comments (adress -> address, layed -> laid, wierd -> weird) 2012-12-07 12:34:11 +01:00
ip_icmp.h
ip_input.c misc: move include files to include/qemu/ 2012-12-19 08:32:39 +01:00
ip_output.c
ip.h
libslirp.h slirp: switch to GPollFD 2013-02-21 16:17:31 -06:00
main.h slirp: switch to GPollFD 2013-02-21 16:17:31 -06:00
Makefile.objs slirp: Add domain-search option to slirp's DHCP server 2012-11-15 10:27:14 +01:00
mbuf.c
mbuf.h
misc.c monitor: move include files to include/monitor/ 2012-12-19 08:31:32 +01:00
misc.h slirp: remove unused function u_sleep 2012-11-10 13:49:20 +00:00
sbuf.c misc: move include files to include/qemu/ 2012-12-19 08:32:39 +01:00
sbuf.h
slirp_config.h
slirp.c slirp: switch to GPollFD 2013-02-21 16:17:31 -06:00
slirp.h slirp: remove unused field tt 2013-01-12 12:26:16 +00:00
socket.c slirp: switch to GPollFD 2013-02-21 16:17:31 -06:00
socket.h slirp: switch to GPollFD 2013-02-21 16:17:31 -06:00
tcp_input.c
tcp_output.c
tcp_subr.c
tcp_timer.c
tcp_timer.h
tcp_var.h
tcp.h
tcpip.h
tftp.c
tftp.h janitor: add guards to headers 2012-12-19 08:31:31 +01:00
udp.c
udp.h