aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSamuel Thibault <samuel.thibault@ens-lyon.org>2021-11-12 00:29:51 +0100
committerSamuel Thibault <samuel.thibault@ens-lyon.org>2021-11-12 00:31:24 +0100
commit99bc3fc61e58fa29eac5577aa4dcaf1ede732d4a (patch)
tree70f99f498305c8892a8da4e204d4903cb6f1ae1f
parent7458e1b6f3217189ee2f01b77dd39563a94cffdf (diff)
downloadslirp-99bc3fc61e58fa29eac5577aa4dcaf1ede732d4a.zip
slirp-99bc3fc61e58fa29eac5577aa4dcaf1ede732d4a.tar.gz
slirp-99bc3fc61e58fa29eac5577aa4dcaf1ede732d4a.tar.bz2
slirp_pollfds_fill: Explain why dividing so_snd.sb_datalen by two
-rw-r--r--src/libslirp.h3
-rw-r--r--src/slirp.c7
2 files changed, 8 insertions, 2 deletions
diff --git a/src/libslirp.h b/src/libslirp.h
index 5760d53..8e4ea33 100644
--- a/src/libslirp.h
+++ b/src/libslirp.h
@@ -68,7 +68,8 @@ typedef struct SlirpCb {
void (*register_poll_fd)(int fd, void *opaque);
/* Unregister a fd */
void (*unregister_poll_fd)(int fd, void *opaque);
- /* Kick the io-thread, to signal that new events may be processed */
+ /* Kick the io-thread, to signal that new events may be processed because some TCP buffer
+ * can now receive more data, i.e. slirp_socket_can_recv will return 1. */
void (*notify)(void *opaque);
} SlirpCb;
diff --git a/src/slirp.c b/src/slirp.c
index 0583e5b..378a70b 100644
--- a/src/slirp.c
+++ b/src/slirp.c
@@ -613,7 +613,10 @@ void slirp_pollfds_fill(Slirp *slirp, uint32_t *timeout,
/*
* Set for reading (and urgent data) if we are connected, can
- * receive more, and we have room for it XXX /2 ?
+ * receive more, and we have room for it.
+ *
+ * If sb is already half full, we will wait for the guest to consume it,
+ * and notify again in sbdrop() when the sb becomes less than half full.
*/
if (CONN_CANFRCV(so) &&
(so->so_snd.sb_cc < (so->so_snd.sb_datalen / 2))) {
@@ -1359,6 +1362,8 @@ size_t slirp_socket_can_recv(Slirp *slirp, struct in_addr guest_addr,
}
if (!CONN_CANFRCV(so) || so->so_snd.sb_cc >= (so->so_snd.sb_datalen / 2)) {
+ /* If the sb is already half full, we will wait for the guest to consume it,
+ * and notify again in sbdrop() when the sb becomes less than half full. */
return 0;
}