diff options
author | Jan Kiszka <jan.kiszka@siemens.com> | 2009-06-24 14:42:30 +0200 |
---|---|---|
committer | Anthony Liguori <aliguori@us.ibm.com> | 2009-06-29 08:52:49 -0500 |
commit | d918f23efaf486293b96418fe5deaff8a5583304 (patch) | |
tree | 59fa071ef2883a5c1a92c305cee42864b8236b3e /slirp | |
parent | 8ec7f4edcfcca6ef5d197f1d9323137ece5f7a89 (diff) |
slirp: Kill slirp_is_inited
Avoid the need for slirp_is_inited by refactoring the protected
slirp_select_* functions. This also avoids the clearing of all fd sets
on select errors.
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Diffstat (limited to 'slirp')
-rw-r--r-- | slirp/libslirp.h | 14 | ||||
-rw-r--r-- | slirp/slirp.c | 20 |
2 files changed, 26 insertions, 8 deletions
diff --git a/slirp/libslirp.h b/slirp/libslirp.h index 8117187f94..b0496d546f 100644 --- a/slirp/libslirp.h +++ b/slirp/libslirp.h @@ -3,6 +3,8 @@ #include <qemu-common.h> +#ifdef CONFIG_SLIRP + void slirp_init(int restricted, struct in_addr vnetwork, struct in_addr vnetmask, struct in_addr vhost, const char *vhostname, const char *tftp_path, @@ -12,7 +14,8 @@ void slirp_init(int restricted, struct in_addr vnetwork, void slirp_select_fill(int *pnfds, fd_set *readfds, fd_set *writefds, fd_set *xfds); -void slirp_select_poll(fd_set *readfds, fd_set *writefds, fd_set *xfds); +void slirp_select_poll(fd_set *readfds, fd_set *writefds, fd_set *xfds, + int select_error); void slirp_input(const uint8_t *pkt, int pkt_len); @@ -32,4 +35,13 @@ void slirp_socket_recv(struct in_addr guest_addr, int guest_port, const uint8_t *buf, int size); size_t slirp_socket_can_recv(struct in_addr guest_addr, int guest_port); +#else /* !CONFIG_SLIRP */ + +static inline void slirp_select_fill(int *pnfds, fd_set *readfds, + fd_set *writefds, fd_set *xfds) { } + +static inline void slirp_select_poll(fd_set *readfds, fd_set *writefds, + fd_set *xfds, int select_error) { } +#endif /* !CONFIG_SLIRP */ + #endif diff --git a/slirp/slirp.c b/slirp/slirp.c index 20c691f3e3..cf52d36ece 100644 --- a/slirp/slirp.c +++ b/slirp/slirp.c @@ -271,6 +271,10 @@ void slirp_select_fill(int *pnfds, int nfds; int tmp_time; + if (!link_up) { + return; + } + /* fail safe */ global_readfds = NULL; global_writefds = NULL; @@ -281,7 +285,7 @@ void slirp_select_fill(int *pnfds, * First, TCP sockets */ do_slowtimo = 0; - if (link_up) { + /* * *_slowtimo needs calling if there are IP fragments * in the fragment queue, or there are TCP connections active @@ -375,7 +379,6 @@ void slirp_select_fill(int *pnfds, UPD_NFDS(so->s); } } - } /* * Setup timeout to use minimum CPU usage, especially when idle @@ -413,11 +416,16 @@ void slirp_select_fill(int *pnfds, *pnfds = nfds; } -void slirp_select_poll(fd_set *readfds, fd_set *writefds, fd_set *xfds) +void slirp_select_poll(fd_set *readfds, fd_set *writefds, fd_set *xfds, + int select_error) { struct socket *so, *so_next; int ret; + if (!link_up) { + return; + } + global_readfds = readfds; global_writefds = writefds; global_xfds = xfds; @@ -428,7 +436,6 @@ void slirp_select_poll(fd_set *readfds, fd_set *writefds, fd_set *xfds) /* * See if anything has timed out */ - if (link_up) { if (time_fasttimo && ((curtime - time_fasttimo) >= 2)) { tcp_fasttimo(); time_fasttimo = 0; @@ -438,12 +445,11 @@ void slirp_select_poll(fd_set *readfds, fd_set *writefds, fd_set *xfds) tcp_slowtimo(); last_slowtimo = curtime; } - } /* * Check sockets */ - if (link_up) { + if (!select_error) { /* * Check TCP sockets */ @@ -576,7 +582,7 @@ void slirp_select_poll(fd_set *readfds, fd_set *writefds, fd_set *xfds) /* * See if we can start outputting */ - if (if_queued && link_up) + if (if_queued) if_start(); /* clear global file descriptor sets. |