GNU libmicrohttpd
0.9.71
|
Implementation of send() wrappers. More...
#include "mhd_send.h"
Go to the source code of this file.
Macros | |
#define | MHD_SENFILE_CHUNK_ (0x20000) |
#define | MHD_SENFILE_CHUNK_THR_P_C_ (0x200000) |
Functions | |
static void | pre_cork_setsockopt (struct MHD_Connection *connection, bool want_cork) |
static void | post_cork_setsockopt (struct MHD_Connection *connection, bool want_cork) |
ssize_t | MHD_send_on_connection_ (struct MHD_Connection *connection, const char *buffer, size_t buffer_size, enum MHD_SendSocketOptions options) |
ssize_t | MHD_send_on_connection2_ (struct MHD_Connection *connection, const char *header, size_t header_size, const char *buffer, size_t buffer_size) |
Implementation of send() wrappers.
Definition in file mhd_send.c.
#define MHD_SENFILE_CHUNK_ (0x20000) |
sendfile() chuck size
Definition at line 466 of file mhd_send.c.
#define MHD_SENFILE_CHUNK_THR_P_C_ (0x200000) |
sendfile() chuck size for thread-per-connection
Definition at line 471 of file mhd_send.c.
ssize_t MHD_send_on_connection2_ | ( | struct MHD_Connection * | connection, |
const char * | header, | ||
size_t | header_size, | ||
const char * | buffer, | ||
size_t | buffer_size | ||
) |
Send header followed by buffer on connection. Uses writev if possible to send both at once and returns the sum of the number of bytes sent from both buffers, or -1 on error; if writev is unavailable, this call MUST only send from 'header' (as we cannot handle the case that the first write succeeds and the 2nd fails!).
connection | the MHD_Connection structure |
header | content of header to send |
header_size | the size of the header (in bytes) |
buffer | content of the buffer to send |
buffer_size | the size of the buffer (in bytes) |
Definition at line 389 of file mhd_send.c.
References MHD_Connection::daemon, MAYBE_MSG_NOSIGNAL, MHD_send_on_connection_(), MHD_SSO_HDR_CORK, MHD_USE_TLS, MHD_Daemon::options, post_cork_setsockopt(), pre_cork_setsockopt(), MHD_Connection::sk_cork_on, and MHD_Connection::socket_fd.
Referenced by MHD_connection_handle_write().
ssize_t MHD_send_on_connection_ | ( | struct MHD_Connection * | connection, |
const char * | buffer, | ||
size_t | buffer_size, | ||
enum MHD_SendSocketOptions | options | ||
) |
Send buffer on connection, and remember the current state of the socket options; only call setsockopt when absolutely necessary.
connection | the MHD_Connection structure |
buffer | content of the buffer to send |
buffer_size | the size of the buffer (in bytes) |
options | the MHD_SendSocketOptions enum, MHD_SSO_NO_CORK: definitely no corking (use NODELAY, or explicitly disable cork), MHD_SSO_MAY_CORK: should enable corking (use MSG_MORE, or explicitly enable cork), MHD_SSO_HDR_CORK: consider tcpi_snd_mss and consider not corking for the header part if the size of the header is close to the MSS. Only used if we are NOT doing 100 Continue and are still sending the header (provided in full as the buffer to MHD_send_on_connection_ or as the header to MHD_send_on_connection2_). |
Definition at line 241 of file mhd_send.c.
References MHD_Connection::daemon, MAYBE_MSG_NOSIGNAL, MHD_CONNECTION_CLOSED, MHD_EPOLL_STATE_WRITE_READY, MHD_ERR_AGAIN_, MHD_ERR_CONNRESET_, MHD_ERR_NOTCONN_, MHD_INVALID_SOCKET, MHD_SCKT_ECONNRESET_, MHD_SCKT_ERR_IS_, MHD_SCKT_ERR_IS_EAGAIN_, MHD_SCKT_ERR_IS_EINTR_, MHD_SCKT_SEND_MAX_SIZE_, MHD_socket_get_error_, MHD_SSO_HDR_CORK, MHD_SSO_MAY_CORK, MHD_SSO_NO_CORK, MHD_USE_TLS, MHD_Daemon::options, post_cork_setsockopt(), pre_cork_setsockopt(), MHD_Connection::sk_cork_on, MHD_Connection::socket_fd, SSIZE_MAX, and MHD_Connection::state.
Referenced by MHD_connection_handle_write(), and MHD_send_on_connection2_().
|
static |
Handle setsockopt calls.
connection | the MHD_Connection structure |
want_cork | cork state, boolean |
Definition at line 137 of file mhd_send.c.
References _, MHD_Connection::daemon, MHD_socket_cork_(), MHD_socket_last_strerr_, MHD_socket_set_nodelay_(), MHD_Connection::sk_cork_on, and MHD_Connection::socket_fd.
Referenced by MHD_send_on_connection2_(), and MHD_send_on_connection_().
|
static |
Handle setsockopt calls.
connection | the MHD_Connection structure |
want_cork | cork state, boolean |
Definition at line 48 of file mhd_send.c.
References _, MHD_Connection::daemon, MHD_socket_cork_(), MHD_socket_last_strerr_, MHD_socket_set_nodelay_(), MHD_Connection::sk_cork_on, and MHD_Connection::socket_fd.
Referenced by MHD_send_on_connection2_(), and MHD_send_on_connection_().