@@ -27,6 +27,8 @@ typedef struct SlirpCb {
void (*timer_free)(void *timer);
/* Modify a timer to expire at @expire_time */
void (*timer_mod)(void *timer, int64_t expire_time);
+ /* Put a fd in nonblocking mode and register it for future polling */
+ void (*set_nonblock)(int fd);
} SlirpCb;
@@ -193,6 +193,7 @@ static const SlirpCb slirp_cb = {
.timer_new = net_slirp_timer_new,
.timer_free = net_slirp_timer_free,
.timer_mod = net_slirp_timer_mod,
+ .set_nonblock = qemu_set_nonblock,
};
static int net_slirp_init(NetClientState *peer, const char *model,
@@ -172,7 +172,7 @@ fork_exec(struct socket *so, const char *ex)
socket_set_fast_reuse(so->s);
opt = 1;
qemu_setsockopt(so->s, SOL_SOCKET, SO_OOBINLINE, &opt, sizeof(int));
- qemu_set_nonblock(so->s);
+ so->slirp->cb->set_nonblock(so->s);
return 1;
}
#endif
@@ -412,7 +412,7 @@ int tcp_fconnect(struct socket *so, unsigned short af)
int opt, s=so->s;
struct sockaddr_storage addr;
- qemu_set_nonblock(s);
+ so->slirp->cb->set_nonblock(s);
socket_set_fast_reuse(s);
opt = 1;
qemu_setsockopt(s, SOL_SOCKET, SO_OOBINLINE, &opt, sizeof(opt));
@@ -484,7 +484,7 @@ void tcp_connect(struct socket *inso)
tcp_close(sototcpcb(so)); /* This will sofree() as well */
return;
}
- qemu_set_nonblock(s);
+ so->slirp->cb->set_nonblock(s);
socket_set_fast_reuse(s);
opt = 1;
qemu_setsockopt(s, SOL_SOCKET, SO_OOBINLINE, &opt, sizeof(int));
qemu_set_nonblock() does some event registration with the main loop on win32, let's have a callback. Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> --- slirp/libslirp.h | 2 ++ net/slirp.c | 1 + slirp/misc.c | 2 +- slirp/tcp_subr.c | 4 ++-- 4 files changed, 6 insertions(+), 3 deletions(-)