slirp: remove the disabled readv()/writev() code path
authorMarc-André Lureau <marcandre.lureau@redhat.com>
Wed, 14 Nov 2018 12:36:14 +0000 (16:36 +0400)
committerSamuel Thibault <samuel.thibault@ens-lyon.org>
Sun, 13 Jan 2019 23:40:54 +0000 (00:40 +0100)
The soread() function may be used on datagram sockets, and would
provide different behaviour if HAVE_READV was set, on empty datagrams.
This looks like a minor optimization, that never has been a strong
goal for slirp.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Signed-off-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
slirp/slirp_config.h
slirp/socket.c

index f0cc1c781bafd9721db0ced3ce827d2d681362a0..3ce64e088ecc607c685390701a468390395a5209 100644 (file)
@@ -29,9 +29,6 @@
 /* Define if the machine is big endian */
 //#undef HOST_WORDS_BIGENDIAN
 
-/* Define if you have readv */
-#undef HAVE_READV
-
 /* Define if iovec needs to be declared */
 #undef DECLARE_IOVEC
 #ifdef _WIN32
index 041ec5061a10247c17c46a7b9b9d809ca2f8f0a8..7012c7c07d7cf510dfeae7b2fcbd599c134014ba 100644 (file)
@@ -187,12 +187,7 @@ soread(struct socket *so)
         */
        sopreprbuf(so, iov, &n);
 
-#ifdef HAVE_READV
-       nn = readv(so->s, (struct iovec *)iov, n);
-       DEBUG_MISC((dfd, " ... read nn = %d bytes\n", nn));
-#else
        nn = qemu_recv(so->s, iov[0].iov_base, iov[0].iov_len,0);
-#endif
        if (nn <= 0) {
                if (nn < 0 && (errno == EINTR || errno == EAGAIN))
                        return 0;
@@ -226,7 +221,6 @@ soread(struct socket *so)
                }
        }
 
-#ifndef HAVE_READV
        /*
         * If there was no error, try and read the second time round
         * We read again if n = 2 (ie, there's another part of the buffer)
@@ -244,7 +238,6 @@ soread(struct socket *so)
         }
 
        DEBUG_MISC((dfd, " ... read nn = %d bytes\n", nn));
-#endif
 
        /* Update fields */
        sb->sb_cc += nn;
@@ -452,13 +445,7 @@ sowrite(struct socket *so)
        }
        /* Check if there's urgent data to send, and if so, send it */
 
-#ifdef HAVE_READV
-       nn = writev(so->s, (const struct iovec *)iov, n);
-
-       DEBUG_MISC((dfd, "  ... wrote nn = %d bytes\n", nn));
-#else
        nn = slirp_send(so, iov[0].iov_base, iov[0].iov_len,0);
-#endif
        /* This should never happen, but people tell me it does *shrug* */
        if (nn < 0 && (errno == EAGAIN || errno == EINTR))
                return 0;
@@ -467,7 +454,6 @@ sowrite(struct socket *so)
                goto err_disconnected;
        }
 
-#ifndef HAVE_READV
        if (n == 2 && nn == iov[0].iov_len) {
             int ret;
             ret = slirp_send(so, iov[1].iov_base, iov[1].iov_len,0);
@@ -475,7 +461,6 @@ sowrite(struct socket *so)
                 nn += ret;
         }
         DEBUG_MISC((dfd, "  ... wrote nn = %d bytes\n", nn));
-#endif
 
        /* Update sbuf */
        sb->sb_cc -= nn;