38#ifdef MHD_LINUX_SOLARIS_SENDFILE
39#include <sys/sendfile.h>
41#if defined(HAVE_FREEBSD_SENDFILE) || defined(HAVE_DARWIN_SENDFILE)
43#include <sys/socket.h>
46#ifdef HAVE_SYS_PARAM_H
58#if (! defined(HAVE_SENDMSG) || ! defined(MSG_NOSIGNAL)) && \
59 defined(MHD_SEND_SPIPE_SUPPRESS_POSSIBLE) && \
60 defined(MHD_SEND_SPIPE_SUPPRESS_NEEDED)
61#define _MHD_VECT_SEND_NEEDS_SPIPE_SUPPRESSED 1
69#define MHD_SENFILE_CHUNK_ (0x20000)
74#define MHD_SENFILE_CHUNK_THR_P_C_ (0x200000)
76#ifdef HAVE_FREEBSD_SENDFILE
117#if defined(HAVE_SYSCONF) && defined(_SC_IOV_MAX)
139#define _MHD_IOV_MAX mhd_iov_max_
140#elif defined(IOV_MAX)
145#define _MHD_IOV_MAX IOV_MAX
155#ifdef HAVE_FREEBSD_SENDFILE
163#if defined(HAVE_SYSCONF) && defined(_SC_IOV_MAX)
202 _ (
"Setting %s option to %s state failed "
203 "for TCP/IP socket %d: %s\n"),
215 _ (
"Setting %s option to %s state failed: %s\n"),
243#if defined(MHD_TCP_CORK_NOPUSH)
271 _ (
"Setting %s option to %s state failed "
272 "for TCP/IP socket %d: %s\n"),
288 _ (
"Setting %s option to %s state failed: %s\n"),
335#ifdef MHD_USE_MSG_MORE
343#ifdef MHD_TCP_CORK_NOPUSH
370#ifdef MHD_TCP_CORK_NOPUSH
371#ifdef _MHD_CORK_RESET_PUSH_DATA
372#ifdef _MHD_CORK_RESET_PUSH_DATA_ALWAYS
386#ifdef _MHD_NODELAY_SET_PUSH_DATA_ALWAYS
395#ifdef _MHD_NODELAY_SET_PUSH_DATA
422#ifdef _MHD_NODELAY_SET_PUSH_DATA
450#ifdef _MHD_NODELAY_SET_PUSH_DATA
491#ifdef _MHD_NODELAY_SET_PUSH_DATA
532#ifndef _MHD_CORK_RESET_PUSH_DATA_ALWAYS
558 _ (
"Zero-send failed: %s\n"),
591#ifndef MHD_USE_MSG_MORE
596#ifdef MHD_TCP_CORK_NOPUSH
597#ifdef _MHD_CORK_RESET_PUSH_DATA_ALWAYS
598#ifdef _MHD_NODELAY_SET_PUSH_DATA_ALWAYS
599#ifdef MHD_USE_MSG_MORE
691#ifdef _MHD_CORK_RESET_PUSH_DATA
698#ifdef _MHD_CORK_RESET_PUSH_DATA
740 _ (
"Failed to push the data from buffers to the network. "
741 "Client may experience some delay "
742 "(usually in range 200ms - 5 sec).\n"));
784 connection->epoll_state &=
802#if defined(GNUTLS_E_PREMATURE_TERMINATION)
805#elif defined(GNUTLS_E_UNEXPECTED_PACKET_LENGTH)
835#ifdef MHD_USE_MSG_MORE
855 connection->epoll_state &=
880 else if (buffer_size > (
size_t)
ret)
881 connection->epoll_state &=
914#define _MHD_SEND_VEC_MAX MHD_SCKT_SEND_MAX_SIZE_
916#define _MHD_SEND_VEC_MAX UINT32_MAX
919#if defined(HAVE_SENDMSG) || defined(HAVE_WRITEV)
935#if (! defined(HAVE_SENDMSG) || ! defined(MSG_NOSIGNAL) ) && \
936 defined(MHD_SEND_SPIPE_SEND_SUPPRESS_POSSIBLE) && \
937 defined(MHD_SEND_SPIPE_SUPPRESS_NEEDED)
986 || ((
size_t)
UINT_MAX < header_size)
998 if ( (header_size == (
size_t)
ret) &&
1039#if (SSIZE_MAX != _MHD_SEND_VEC_MAX) || (_MHD_SEND_VEC_MAX + 0 == 0)
1057#if defined(HAVE_SENDMSG) || defined(HAVE_WRITEV)
1058 vector[0].iov_base = (
void *) header;
1059 vector[0].iov_len = header_size;
1063#if defined(HAVE_SENDMSG)
1069#elif defined(HAVE_WRITEV)
1081 vector[0].buf = (
char *) header;
1101 connection->epoll_state &=
1127 connection->epoll_state &=
1151 (header_size <= (
size_t)
ret))
1173#if defined(_MHD_HAVE_SENDFILE)
1181#ifndef HAVE_SENDFILE64
1186#ifdef MHD_LINUX_SOLARIS_SENDFILE
1187#ifndef HAVE_SENDFILE64
1193#ifdef HAVE_FREEBSD_SENDFILE
1197#ifdef HAVE_DARWIN_SENDFILE
1236#ifdef MHD_LINUX_SOLARIS_SENDFILE
1237#ifndef HAVE_SENDFILE64
1257 connection->epoll_state &=
1264#ifdef HAVE_LINUX_SENDFILE
1293 connection->epoll_state &=
1296#elif defined(HAVE_FREEBSD_SENDFILE)
1328#elif defined(HAVE_DARWIN_SENDFILE)
1381#if defined(MHD_VECT_SEND)
1407#elif defined(MHD_WINSOCK_SOCKETS)
1437#ifdef MHD_USE_MSG_MORE
1443#elif defined(HAVE_WRITEV)
1447#elif defined(MHD_WINSOCK_SOCKETS)
1468#error No vector-send function available
1479 connection->epoll_state &=
1520 connection->epoll_state &=
1539#if ! defined(MHD_VECT_SEND) || defined(HTTPS_SUPPORT) || \
1540 defined(_MHD_VECT_SEND_NEEDS_SPIPE_SUPPRESSED)
1619#if defined(HTTPS_SUPPORT) || \
1620 defined(_MHD_VECT_SEND_NEEDS_SPIPE_SUPPRESSED)
1629#if defined(HTTPS_SUPPORT) || \
1630 defined(_MHD_VECT_SEND_NEEDS_SPIPE_SUPPRESSED)
1635#ifdef _MHD_VECT_SEND_NEEDS_SPIPE_SUPPRESSED
1644#if ! defined(MHD_VECT_SEND) || defined(HTTPS_SUPPORT) || \
1645 defined(_MHD_VECT_SEND_NEEDS_SPIPE_SUPPRESSED)
#define MHD_ERR_OPNOTSUPP_
#define MHD_ERR_CONNRESET_
@ MHD_EPOLL_STATE_WRITE_READY
#define MHD_SCKT_ERR_IS_(err, code)
#define MHD_SCKT_ERR_IS_EAGAIN_(err)
#define MHD_SCKT_ERR_IS_LOW_RESOURCES_(err)
#define MHD_socket_strerr_(err)
#define MHD_socket_last_strerr_()
#define MHD_SCKT_EOPNOTSUPP_
#define MHD_socket_get_error_()
#define MHD_SCKT_ERR_IS_REMOTE_DISCNN_(err)
#define MHD_SCKT_ERR_IS_EINTR_(err)
#define MHD_SCKT_SEND_MAX_SIZE_
#define MHD_SCKT_ENOTCONN_
#define MHD_SCKT_ENOTSOCK_
#define MHD_send_(s, b, l)
#define MHD_SENFILE_CHUNK_THR_P_C_
ssize_t MHD_send_hdr_and_body_(struct MHD_Connection *connection, const char *header, size_t header_size, bool never_push_hdr, const char *body, size_t body_size, bool complete_response)
ssize_t MHD_send_iovec_(struct MHD_Connection *connection, struct MHD_iovec_track_ *const r_iov, bool push_data)
ssize_t MHD_send_data_(struct MHD_Connection *connection, const char *buffer, size_t buffer_size, bool push_data)
static bool zero_send_(struct MHD_Connection *connection)
bool MHD_connection_set_cork_state_(struct MHD_Connection *connection, bool cork_state)
#define _MHD_SEND_VEC_MAX
void MHD_send_init_static_vars_(void)
static void pre_send_setopt(struct MHD_Connection *connection, bool plain_send, bool push_data)
static void post_send_setopt(struct MHD_Connection *connection, bool plain_send_next, bool push_data)
static ssize_t send_iov_emu(struct MHD_Connection *connection, struct MHD_iovec_track_ *const r_iov, bool push_data)
bool MHD_connection_set_nodelay_state_(struct MHD_Connection *connection, bool nodelay_state)
#define MHD_SENFILE_CHUNK_
Declarations of send() wrappers.
limits values definitions
#define MHD_SCKT_ENOPROTOOPT_
#define MHD_send4_(s, b, l, f)
#define MSG_NOSIGNAL_OR_ZERO
#define MHD_INVALID_SOCKET
@ MHD_USE_THREAD_PER_CONNECTION
enum MHD_tristate sk_nodelay
enum MHD_tristate is_nonip
struct MHD_Response * response
uint64_t response_write_position
struct MHD_iovec_track_ resp_iov
enum MHD_CONNECTION_STATE state
struct MHD_Daemon * daemon
enum MHD_tristate sk_corked