[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 13/31] slirp: add unregister_poll_fd() callback
From: |
Samuel Thibault |
Subject: |
[Qemu-devel] [PULL 13/31] slirp: add unregister_poll_fd() callback |
Date: |
Sun, 27 Jan 2019 13:05:08 +0100 |
From: Marc-André Lureau <address@hidden>
Add a counter-part to register_poll_fd() for completeness.
(so far, register_poll_fd() is called only on struct socket fd)
Suggested-by: Paolo Bonzini <address@hidden>
Signed-off-by: Marc-André Lureau <address@hidden>
Signed-off-by: Samuel Thibault <address@hidden>
---
net/slirp.c | 6 ++++++
slirp/ip_icmp.c | 1 +
slirp/libslirp.h | 2 ++
slirp/slirp.c | 3 ++-
slirp/tcp_subr.c | 2 ++
slirp/udp.c | 1 +
6 files changed, 14 insertions(+), 1 deletion(-)
diff --git a/net/slirp.c b/net/slirp.c
index 6f756a4dcc..78ba96b63f 100644
--- a/net/slirp.c
+++ b/net/slirp.c
@@ -191,6 +191,11 @@ static void net_slirp_register_poll_fd(int fd)
qemu_fd_register(fd);
}
+static void net_slirp_unregister_poll_fd(int fd)
+{
+ /* no qemu_fd_unregister */
+}
+
static const SlirpCb slirp_cb = {
.output = net_slirp_output,
.guest_error = net_slirp_guest_error,
@@ -199,6 +204,7 @@ static const SlirpCb slirp_cb = {
.timer_free = net_slirp_timer_free,
.timer_mod = net_slirp_timer_mod,
.register_poll_fd = net_slirp_register_poll_fd,
+ .unregister_poll_fd = net_slirp_unregister_poll_fd,
};
static int net_slirp_init(NetClientState *peer, const char *model,
diff --git a/slirp/ip_icmp.c b/slirp/ip_icmp.c
index b59daa801d..19e247f773 100644
--- a/slirp/ip_icmp.c
+++ b/slirp/ip_icmp.c
@@ -114,6 +114,7 @@ static int icmp_send(struct socket *so, struct mbuf *m, int
hlen)
void icmp_detach(struct socket *so)
{
+ so->slirp->cb->unregister_poll_fd(so->s);
slirp_closesocket(so->s);
sofree(so);
}
diff --git a/slirp/libslirp.h b/slirp/libslirp.h
index 70e99139bf..8ce69f0be3 100644
--- a/slirp/libslirp.h
+++ b/slirp/libslirp.h
@@ -29,6 +29,8 @@ typedef struct SlirpCb {
void (*timer_mod)(void *timer, int64_t expire_time);
/* Register a fd for future polling */
void (*register_poll_fd)(int fd);
+ /* Unregister a fd */
+ void (*unregister_poll_fd)(int fd);
} SlirpCb;
diff --git a/slirp/slirp.c b/slirp/slirp.c
index 12677e5da7..f0bd59fd6f 100644
--- a/slirp/slirp.c
+++ b/slirp/slirp.c
@@ -1015,7 +1015,8 @@ int slirp_remove_hostfwd(Slirp *slirp, int is_udp, struct
in_addr host_addr,
getsockname(so->s, (struct sockaddr *)&addr, &addr_len) == 0 &&
addr.sin_addr.s_addr == host_addr.s_addr &&
addr.sin_port == port) {
- close(so->s);
+ so->slirp->cb->unregister_poll_fd(so->s);
+ slirp_closesocket(so->s);
sofree(so);
return 0;
}
diff --git a/slirp/tcp_subr.c b/slirp/tcp_subr.c
index 8087ffc047..d8846a33b0 100644
--- a/slirp/tcp_subr.c
+++ b/slirp/tcp_subr.c
@@ -337,6 +337,7 @@ tcp_close(struct tcpcb *tp)
/* clobber input socket cache if we're closing the cached connection */
if (so == slirp->tcp_last_so)
slirp->tcp_last_so = &slirp->tcb;
+ so->slirp->cb->unregister_poll_fd(so->s);
slirp_closesocket(so->s);
sbfree(&so->so_rcv);
sbfree(&so->so_snd);
@@ -498,6 +499,7 @@ void tcp_connect(struct socket *inso)
/* Close the accept() socket, set right state */
if (inso->so_state & SS_FACCEPTONCE) {
/* If we only accept once, close the accept() socket */
+ so->slirp->cb->unregister_poll_fd(so->s);
slirp_closesocket(so->s);
/* Don't select it yet, even though we have an FD */
diff --git a/slirp/udp.c b/slirp/udp.c
index 6c3fb9a29f..3915971b50 100644
--- a/slirp/udp.c
+++ b/slirp/udp.c
@@ -292,6 +292,7 @@ udp_attach(struct socket *so, unsigned short af)
void
udp_detach(struct socket *so)
{
+ so->slirp->cb->unregister_poll_fd(so->s);
slirp_closesocket(so->s);
sofree(so);
}
--
2.20.1
- [Qemu-devel] [PULL 02/31] slirp: Avoid marking naturally packed structs as QEMU_PACKED, (continued)
- [Qemu-devel] [PULL 02/31] slirp: Avoid marking naturally packed structs as QEMU_PACKED, Samuel Thibault, 2019/01/27
- [Qemu-devel] [PULL 07/31] net/slirp: fix leaks on forwarding rule registration error, Samuel Thibault, 2019/01/27
- [Qemu-devel] [PULL 04/31] slirp: generalize guestfwd with a callback based approach, Samuel Thibault, 2019/01/27
- [Qemu-devel] [PULL 19/31] slirp: remove qemu timer.h dependency, Samuel Thibault, 2019/01/27
- [Qemu-devel] [PULL 08/31] slirp: add callbacks for timer, Samuel Thibault, 2019/01/27
- [Qemu-devel] [PULL 14/31] slirp: replace qemu_notify_event() with a callback, Samuel Thibault, 2019/01/27
- [Qemu-devel] [PULL 23/31] slirp: replace QEMU_BUILD_BUG_ON with G_STATIC_ASSERT, Samuel Thibault, 2019/01/27
- [Qemu-devel] [PULL 09/31] slirp: replace trace functions with DEBUG calls, Samuel Thibault, 2019/01/27
- [Qemu-devel] [PULL 03/31] slirp: Don't mark struct ipq or struct ipasfrag as packed, Samuel Thibault, 2019/01/27
- [Qemu-devel] [PULL 16/31] slirp: do not include qemu headers in libslirp.h public API header, Samuel Thibault, 2019/01/27
- [Qemu-devel] [PULL 13/31] slirp: add unregister_poll_fd() callback,
Samuel Thibault <=
- [Qemu-devel] [PULL 28/31] slirp: remove slirp_instances list, Samuel Thibault, 2019/01/27
- [Qemu-devel] [PULL 10/31] slirp: replace QEMU_PACKED with SLIRP_PACKED, Samuel Thibault, 2019/01/27
- [Qemu-devel] [PULL 12/31] slirp: replace qemu_set_nonblock(), Samuel Thibault, 2019/01/27
- [Qemu-devel] [PULL 17/31] slirp: improve windows headers inclusion, Samuel Thibault, 2019/01/27
- [Qemu-devel] [PULL 15/31] slirp: move QEMU state saving to a separate unit, Samuel Thibault, 2019/01/27
- [Qemu-devel] [PULL 18/31] slirp: add slirp own version of pstrcpy, Samuel Thibault, 2019/01/27
- [Qemu-devel] [PULL 21/31] slirp: replace net/eth.h inclusion with own defines, Samuel Thibault, 2019/01/27
- [Qemu-devel] [PULL 11/31] slirp: replace most qemu socket utilities with slirp own version, Samuel Thibault, 2019/01/27
- [Qemu-devel] [PULL 20/31] slirp: remove now useless QEMU headers inclusions, Samuel Thibault, 2019/01/27
- [Qemu-devel] [PULL 31/31] slirp: API is extern C, Samuel Thibault, 2019/01/27