[Slirp] [Git][slirp/libslirp][master] slirp_pollfds_fill: Explain why dividing so_snd.sb_datalen by two

Samuel Thibault (@sthibaul) gitlab at gitlab.freedesktop.org
Thu Nov 11 23:31:44 UTC 2021



Samuel Thibault pushed to branch master at slirp / libslirp


Commits:
99bc3fc6 by Samuel Thibault at 2021-11-12T00:31:24+01:00
slirp_pollfds_fill: Explain why dividing so_snd.sb_datalen by two

- - - - -


2 changed files:

- src/libslirp.h
- src/slirp.c


Changes:

=====================================
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;
 


=====================================
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;
     }
 



View it on GitLab: https://gitlab.freedesktop.org/slirp/libslirp/-/commit/99bc3fc61e58fa29eac5577aa4dcaf1ede732d4a

-- 
View it on GitLab: https://gitlab.freedesktop.org/slirp/libslirp/-/commit/99bc3fc61e58fa29eac5577aa4dcaf1ede732d4a
You're receiving this email because of your account on gitlab.freedesktop.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/slirp/attachments/20211111/5fa12cb9/attachment-0001.htm>


More information about the Slirp mailing list