aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEvgeny Grin (Karlson2k) <k2k@narod.ru>2021-04-15 12:43:01 +0300
committerEvgeny Grin (Karlson2k) <k2k@narod.ru>2021-04-15 12:43:01 +0300
commitddf368bb6d1093657ab29cb5af894bdc2b93788f (patch)
tree9fa90046e8896a0a6b1513ec662b64a559cf217d
parent7762278bd16a304715b086f5709e8671c4f5a9ec (diff)
downloadlibmicrohttpd-ddf368bb6d1093657ab29cb5af894bdc2b93788f.tar.gz
libmicrohttpd-ddf368bb6d1093657ab29cb5af894bdc2b93788f.zip
mhd_send: do not push incomplete responses with vector send
-rw-r--r--src/microhttpd/mhd_send.c16
1 files changed, 13 insertions, 3 deletions
diff --git a/src/microhttpd/mhd_send.c b/src/microhttpd/mhd_send.c
index f691cc7d..c237d469 100644
--- a/src/microhttpd/mhd_send.c
+++ b/src/microhttpd/mhd_send.c
@@ -1288,18 +1288,20 @@ send_iov_nontls (struct MHD_Connection *connection,
1288 return MHD_ERR_NOTCONN_; 1288 return MHD_ERR_NOTCONN_;
1289 } 1289 }
1290 1290
1291 pre_send_setopt (connection, true, push_data);
1292
1293 items_to_send = r_iov->cnt - r_iov->sent; 1291 items_to_send = r_iov->cnt - r_iov->sent;
1294#ifdef IOV_MAX 1292#ifdef IOV_MAX
1295 if (IOV_MAX < items_to_send) 1293 if (IOV_MAX < items_to_send)
1294 {
1296 items_to_send = IOV_MAX; 1295 items_to_send = IOV_MAX;
1296 push_data = false; /* Incomplete response */
1297 }
1297#endif /* IOV_MAX */ 1298#endif /* IOV_MAX */
1298#ifdef HAVE_SENDMSG 1299#ifdef HAVE_SENDMSG
1299 memset (&msg, 0, sizeof(struct msghdr)); 1300 memset (&msg, 0, sizeof(struct msghdr));
1300 msg.msg_iov = r_iov->iov + r_iov->sent; 1301 msg.msg_iov = r_iov->iov + r_iov->sent;
1301 msg.msg_iovlen = items_to_send; 1302 msg.msg_iovlen = items_to_send;
1302 1303
1304 pre_send_setopt (connection, true, push_data);
1303#ifdef MHD_USE_MSG_MORE 1305#ifdef MHD_USE_MSG_MORE
1304 res = sendmsg (connection->socket_fd, &msg, 1306 res = sendmsg (connection->socket_fd, &msg,
1305 MSG_NOSIGNAL_OR_ZERO | (push_data ? 0 : MSG_MORE)); 1307 MSG_NOSIGNAL_OR_ZERO | (push_data ? 0 : MSG_MORE));
@@ -1307,14 +1309,22 @@ send_iov_nontls (struct MHD_Connection *connection,
1307 res = sendmsg (connection->socket_fd, &msg, MSG_NOSIGNAL_OR_ZERO); 1309 res = sendmsg (connection->socket_fd, &msg, MSG_NOSIGNAL_OR_ZERO);
1308#endif /* ! MHD_USE_MSG_MORE */ 1310#endif /* ! MHD_USE_MSG_MORE */
1309#elif defined(HAVE_WRITEV) 1311#elif defined(HAVE_WRITEV)
1312 pre_send_setopt (connection, true, push_data);
1310 res = writev (connection->socket_fd, r_iov->iov + r_iov->sent, 1313 res = writev (connection->socket_fd, r_iov->iov + r_iov->sent,
1311 items_to_send); 1314 items_to_send);
1312#elif defined(MHD_WINSOCK_SOCKETS) 1315#elif defined(MHD_WINSOCK_SOCKETS)
1313#ifdef _WIN64 1316#ifdef _WIN64
1314 cnt_w = (items_to_send > UINT32_MAX) ? UINT32_MAX : (DWORD) items_to_send; 1317 if (items_to_send > UINT32_MAX)
1318 {
1319 cnt_w = UINT32_MAX;
1320 push_data = false; /* Incomplete response */
1321 }
1322 else
1323 cnt_w = (DWORD) items_to_send;
1315#else /* ! _WIN64 */ 1324#else /* ! _WIN64 */
1316 cnt_w = (DWORD) items_to_send; 1325 cnt_w = (DWORD) items_to_send;
1317#endif /* ! _WIN64 */ 1326#endif /* ! _WIN64 */
1327 pre_send_setopt (connection, true, push_data);
1318 if (0 == WSASend (connection->socket_fd, 1328 if (0 == WSASend (connection->socket_fd,
1319 (LPWSABUF) (r_iov->iov + r_iov->sent), 1329 (LPWSABUF) (r_iov->iov + r_iov->sent),
1320 cnt_w, 1330 cnt_w,