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(-)
diff --git a/slirp/libslirp.h b/slirp/libslirp.h
index 3e75dadfa3..e79a2d2b11 100644
--- a/slirp/libslirp.h
+++ b/slirp/libslirp.h
@@ -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;
diff --git a/net/slirp.c b/net/slirp.c
index f7cdf8398b..a31193a25a 100644
--- a/net/slirp.c
+++ b/net/slirp.c
@@ -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,
diff --git a/slirp/misc.c b/slirp/misc.c
index f9b2c64541..7789cefefa 100644
--- a/slirp/misc.c
+++ b/slirp/misc.c
@@ -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
diff --git a/slirp/tcp_subr.c b/slirp/tcp_subr.c
index 5dcf979c3c..3b15148187 100644
--- a/slirp/tcp_subr.c
+++ b/slirp/tcp_subr.c
@@ -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));
--
2.20.0.rc1