GNU libmicrohttpd  0.9.70
mhd_send.c File Reference

Implementation of send() wrappers. More...

#include "mhd_send.h"
Include dependency graph for mhd_send.c:

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)
 

Detailed Description

Implementation of send() wrappers.

Author
ng0 (N. Gillmann)
Christian Grothoff
Evgeny Grin

Definition in file mhd_send.c.

Macro Definition Documentation

◆ MHD_SENFILE_CHUNK_

#define MHD_SENFILE_CHUNK_   (0x20000)

sendfile() chuck size

Definition at line 455 of file mhd_send.c.

◆ MHD_SENFILE_CHUNK_THR_P_C_

#define MHD_SENFILE_CHUNK_THR_P_C_   (0x200000)

sendfile() chuck size for thread-per-connection

Definition at line 460 of file mhd_send.c.

Function Documentation

◆ MHD_send_on_connection2_()

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!).

Parameters
connectionthe MHD_Connection structure
headercontent of header to send
header_sizethe size of the header (in bytes)
buffercontent of the buffer to send
buffer_sizethe size of the buffer (in bytes)
Returns
sum of the number of bytes sent from both buffers or -1 on error

Definition at line 378 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().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ MHD_send_on_connection_()

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.

Parameters
connectionthe MHD_Connection structure
buffercontent of the buffer to send
buffer_sizethe size of the buffer (in bytes)
optionsthe 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_).
Returns
sum of the number of bytes sent from both buffers or -1 on error

Definition at line 233 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_().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ post_cork_setsockopt()

static void post_cork_setsockopt ( struct MHD_Connection connection,
bool  want_cork 
)
static

Handle setsockopt calls.

Parameters
connectionthe MHD_Connection structure
want_corkcork state, boolean

Definition at line 133 of file mhd_send.c.

References _, 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_().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ pre_cork_setsockopt()

static void pre_cork_setsockopt ( struct MHD_Connection connection,
bool  want_cork 
)
static

Handle setsockopt calls.

Parameters
connectionthe MHD_Connection structure
want_corkcork state, boolean

Definition at line 48 of file mhd_send.c.

References _, 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_().

Here is the call graph for this function:
Here is the caller graph for this function: