57 #elif defined(MHD_TCP_CORK_NOPUSH) 87 MHD_DLOG (connection->
daemon,
88 _ (
"optlen invalid: %s\n"),
95 MHD_DLOG (connection->
daemon,
97 "The address pointed to by optval is not a valid part of the process address space: %s\n"),
104 MHD_DLOG (connection->
daemon,
105 _ (
"The option is unknown: %s\n"),
146 #elif defined(MHD_TCP_CORK_NOPUSH) 178 MHD_DLOG (connection->
daemon,
179 _ (
"optlen invalid: %s\n"),
186 MHD_DLOG (connection->
daemon,
188 "The address pointed to by optval is not a valid part of the process address space: %s\n"),
195 MHD_DLOG (connection->
daemon,
196 _ (
"The option is unknown: %s\n"),
213 if ( (! want_cork) &&
274 want_cork = (buffer_size <= 1024);
283 if (want_cork && ! have_cork)
285 gnutls_record_cork (connection->tls_session);
290 ret = gnutls_record_send (connection->tls_session,
293 if ( (GNUTLS_E_AGAIN == ret) ||
294 (GNUTLS_E_INTERRUPTED == ret) )
297 if (GNUTLS_E_AGAIN == ret)
314 if (! want_cork && have_cork)
316 int err = gnutls_record_uncork (connection->tls_session, 0);
360 else if (buffer_size > (
size_t) ret)
363 if (buffer_size == (
size_t) ret)
404 if ( (header_size == (
size_t) ret) &&
405 (0 == buffer_size) &&
408 (void) gnutls_record_uncork (connection->tls_session, 0);
414 #if defined(HAVE_SENDMSG) || defined(HAVE_WRITEV) 417 struct iovec vector[2];
423 vector[0].iov_base = (
void *) header;
424 vector[0].iov_len = header_size;
425 vector[1].iov_base = (
void *) buffer;
426 vector[1].iov_len = buffer_size;
432 memset (&msg, 0,
sizeof(
struct msghdr));
433 msg.msg_iov = vector;
442 iovcnt =
sizeof (vector) /
sizeof (
struct iovec);
443 ret = writev (s, vector, iovcnt);
449 if (header_size + buffer_size == (
size_t) ret)
466 #define MHD_SENFILE_CHUNK_ (0x20000) 471 #define MHD_SENFILE_CHUNK_THR_P_C_ (0x200000) 473 #ifdef HAVE_FREEBSD_SENDFILE 478 static int freebsd_sendfile_flags_;
483 static int freebsd_sendfile_flags_thd_p_c_;
488 #if defined(_MHD_HAVE_SENDFILE) 502 #ifndef HAVE_SENDFILE64 503 const uint64_t max_off_t = (uint64_t)
OFF_T_MAX;
505 const uint64_t max_off_t = (uint64_t) OFF64_T_MAX;
507 #ifdef MHD_LINUX_SOLARIS_SENDFILE 508 #ifndef HAVE_SENDFILE64 514 #ifdef HAVE_FREEBSD_SENDFILE 518 #ifdef HAVE_DARWIN_SENDFILE 525 size_t send_size = 0;
526 mhd_assert (MHD_resp_sender_sendfile == connection->resp_sender);
535 send_size = (left > chunk_size) ? chunk_size : (
size_t) left;
536 if (max_off_t < offsetu64)
538 connection->resp_sender = MHD_resp_sender_std;
541 #ifdef MHD_LINUX_SOLARIS_SENDFILE 542 #ifndef HAVE_SENDFILE64 543 offset = (off_t) offsetu64;
549 offset = (off64_t) offsetu64;
568 #ifdef HAVE_LINUX_SENDFILE 576 connection->resp_sender = MHD_resp_sender_std;
579 if ( (EAFNOSUPPORT == err) ||
581 (EOPNOTSUPP == err) )
583 connection->resp_sender = MHD_resp_sender_std;
586 if ( (ENOTCONN == err) ||
595 else if (send_size > (
size_t) ret)
598 #elif defined(HAVE_FREEBSD_SENDFILE) 600 flags = used_thr_p_c ?
601 freebsd_sendfile_flags_thd_p_c_ : freebsd_sendfile_flags_;
603 if (0 != sendfile (file_fd,
618 return (ssize_t) sent_bytes;
624 connection->resp_sender = MHD_resp_sender_std;
629 ret = (ssize_t) sent_bytes;
630 #elif defined(HAVE_DARWIN_SENDFILE) 631 len = (off_t) send_size;
632 if (0 != sendfile (file_fd,
647 return (ssize_t) len;
651 if ((ENOTCONN == err) ||
654 if ((ENOTSUP == err) ||
655 (EOPNOTSUPP == err) )
658 connection->resp_sender = MHD_resp_sender_std;
671 if (left == (uint64_t) ret)
static void pre_cork_setsockopt(struct MHD_Connection *connection, bool want_cork)
enum MHD_CONNECTION_STATE state
uint64_t response_write_position
#define MHD_socket_get_error_()
struct MHD_Response * response
#define MHD_SENFILE_CHUNK_
#define MHD_SCKT_ERR_IS_EAGAIN_(err)
#define MAYBE_MSG_NOSIGNAL
int MHD_socket_cork_(MHD_socket sock, bool on)
#define MHD_ERR_CONNRESET_
ssize_t MHD_send_on_connection2_(struct MHD_Connection *connection, const char *header, size_t header_size, const char *buffer, size_t buffer_size)
struct MHD_Daemon * daemon
#define MHD_socket_last_strerr_()
#define MHD_INVALID_SOCKET
#define MHD_SCKT_SEND_MAX_SIZE_
#define MHD_SCKT_ERR_IS_(err, code)
ssize_t MHD_send_on_connection_(struct MHD_Connection *connection, const char *buffer, size_t buffer_size, enum MHD_SendSocketOptions options)
Implementation of send() wrappers.
int MHD_socket_set_nodelay_(MHD_socket sock, bool on)
#define MHD_SCKT_ECONNRESET_
#define MHD_SCKT_ERR_IS_EINTR_(err)
#define MHD_SENFILE_CHUNK_THR_P_C_
static void post_cork_setsockopt(struct MHD_Connection *connection, bool want_cork)