diff options
author | Evgeny Grin (Karlson2k) <k2k@narod.ru> | 2020-12-13 17:37:14 +0300 |
---|---|---|
committer | Evgeny Grin (Karlson2k) <k2k@narod.ru> | 2020-12-13 17:37:14 +0300 |
commit | 526de1a8e1da6a1e5509bd12775c7a1795370bc8 (patch) | |
tree | 01235d65e3740fb1666c2d85b550b6faaa4d9d2b /src/microhttpd/mhd_send.c | |
parent | 75e49713c671acc9d0df6167b23bbb0c1273b8df (diff) | |
download | libmicrohttpd-526de1a8e1da6a1e5509bd12775c7a1795370bc8.tar.gz libmicrohttpd-526de1a8e1da6a1e5509bd12775c7a1795370bc8.zip |
MHD_send_hdr_and_body_: streamlined code
Diffstat (limited to 'src/microhttpd/mhd_send.c')
-rw-r--r-- | src/microhttpd/mhd_send.c | 34 |
1 files changed, 14 insertions, 20 deletions
diff --git a/src/microhttpd/mhd_send.c b/src/microhttpd/mhd_send.c index 8abd30d6..1f187902 100644 --- a/src/microhttpd/mhd_send.c +++ b/src/microhttpd/mhd_send.c | |||
@@ -822,6 +822,9 @@ MHD_send_hdr_and_body_ (struct MHD_Connection *connection, | |||
822 | #if defined(HAVE_SENDMSG) || defined(HAVE_WRITEV) | 822 | #if defined(HAVE_SENDMSG) || defined(HAVE_WRITEV) |
823 | MHD_socket s = connection->socket_fd; | 823 | MHD_socket s = connection->socket_fd; |
824 | struct iovec vector[2]; | 824 | struct iovec vector[2]; |
825 | #ifdef HAVE_SENDMSG | ||
826 | struct msghdr msg; | ||
827 | #endif /* HAVE_SENDMSG */ | ||
825 | #ifdef HTTPS_SUPPORT | 828 | #ifdef HTTPS_SUPPORT |
826 | const bool no_vec = (connection->daemon->options & MHD_USE_TLS); | 829 | const bool no_vec = (connection->daemon->options & MHD_USE_TLS); |
827 | #else /* ! HTTPS_SUPPORT */ | 830 | #else /* ! HTTPS_SUPPORT */ |
@@ -925,28 +928,19 @@ MHD_send_hdr_and_body_ (struct MHD_Connection *connection, | |||
925 | vector[1].iov_len = body_size; | 928 | vector[1].iov_len = body_size; |
926 | 929 | ||
927 | #if HAVE_SENDMSG | 930 | #if HAVE_SENDMSG |
928 | { | 931 | memset (&msg, 0, sizeof(struct msghdr)); |
929 | struct msghdr msg; | 932 | msg.msg_iov = vector; |
930 | 933 | msg.msg_iovlen = 2; | |
931 | memset (&msg, 0, sizeof(struct msghdr)); | ||
932 | msg.msg_iov = vector; | ||
933 | msg.msg_iovlen = 2; | ||
934 | 934 | ||
935 | ret = sendmsg (s, &msg, MSG_NOSIGNAL_OR_ZERO); | 935 | ret = sendmsg (s, &msg, MSG_NOSIGNAL_OR_ZERO); |
936 | if ( (-1 == ret) && | 936 | if ( (-1 == ret) && |
937 | (EAGAIN == errno) ) | 937 | (EAGAIN == errno) ) |
938 | return MHD_ERR_AGAIN_; | 938 | return MHD_ERR_AGAIN_; |
939 | } | ||
940 | #elif HAVE_WRITEV | 939 | #elif HAVE_WRITEV |
941 | { | 940 | ret = writev (s, vector, 2); |
942 | int iovcnt; | 941 | if ( (-1 == ret) && |
943 | 942 | (EAGAIN == errno) ) | |
944 | iovcnt = sizeof (vector) / sizeof (struct iovec); | 943 | return MHD_ERR_AGAIN_; |
945 | ret = writev (s, vector, iovcnt); | ||
946 | if ( (-1 == ret) && | ||
947 | (EAGAIN == errno) ) | ||
948 | return MHD_ERR_AGAIN_; | ||
949 | } | ||
950 | #endif | 944 | #endif |
951 | 945 | ||
952 | /* If there is a need to push the data from network buffers | 946 | /* If there is a need to push the data from network buffers |