GNU libmicrohttpd 0.9.77
|
functions to add connection to our active set More...
#include "internal.h"
#include "connection_add.h"
#include "connection_call_handlers.h"
#include "connection_close.h"
#include "connection_finish_forward.h"
#include "connection_update_last_activity.h"
#include "daemon_ip_limit.h"
#include "daemon_select.h"
#include "daemon_poll.h"
#include "mhd_sockets.h"
Go to the source code of this file.
Macros | |
#define | EXTRA_SLOTS 0 |
Functions | |
static MHD_THRD_RTRN_TYPE_ MHD_THRD_CALL_SPEC_ | thread_main_handle_connection (void *data) |
static ssize_t | recv_param_adapter (struct MHD_Connection *connection, void *other, size_t i) |
static ssize_t | send_param_adapter (struct MHD_Connection *connection, const void *other, size_t i) |
static enum MHD_StatusCode | internal_add_connection (struct MHD_Daemon *daemon, MHD_socket client_socket, const struct sockaddr *addr, socklen_t addrlen, bool external_add, bool non_blck) |
enum MHD_StatusCode | MHD_daemon_add_connection (struct MHD_Daemon *daemon, MHD_socket client_socket, const struct sockaddr *addr, socklen_t addrlen) |
enum MHD_StatusCode | MHD_accept_connection_ (struct MHD_Daemon *daemon) |
functions to add connection to our active set
Definition in file connection_add.c.
#define EXTRA_SLOTS 0 |
|
static |
Add another client connection to the set of connections managed by MHD. This API is usually not needed (since MHD will accept inbound connections on the server socket). Use this API in special cases, for example if your HTTP server is behind NAT and needs to connect out to the HTTP client.
The given client socket will be managed (and closed!) by MHD after this call and must no longer be used directly by the application afterwards.
daemon | daemon that manages the connection |
client_socket | socket to manage (MHD will expect to receive an HTTP request from this socket next). |
addr | IP address of the client |
addrlen | number of bytes in addr |
external_add | perform additional operations needed due to the application calling us directly |
non_blck | indicate that socket in non-blocking mode |
Definition at line 588 of file connection_add.c.
References _, MHD_Daemon::accept_policy_cb, MHD_Daemon::accept_policy_cb_cls, MHD_Connection::addr, MHD_Connection::addr_len, MHD_Daemon::cleanup_connection_mutex, MHD_Daemon::connection_default_timeout, MHD_Daemon::connection_memory_limit_b, MHD_Connection::connection_timeout, MHD_Daemon::connections, MHD_Daemon::connections_head, MHD_Daemon::connections_tail, MHD_Connection::daemon, DLL_insert, DLL_remove, EDLL_insert, MHD_Daemon::enable_turbo, MHD_Daemon::event_loop_syscall, MHD_Daemon::global_connection_limit, internal_add_connection(), MHD_Daemon::itc, MHD_Connection::last_activity, mhd_assert, MHD_calloc_(), MHD_CONNECTION_NOTIFY_CLOSED, MHD_CONNECTION_NOTIFY_STARTED, MHD_create_named_thread_, MHD_EPOLL_STATE_IN_EPOLL_SET, MHD_EPOLL_STATE_IN_EREADY_EDLL, MHD_EPOLL_STATE_READ_READY, MHD_EPOLL_STATE_WRITE_READY, MHD_ip_limit_add(), MHD_ip_limit_del(), MHD_monotonic_sec_counter(), MHD_mutex_lock_chk_, MHD_mutex_unlock_chk_, MHD_NO, MHD_pool_create(), MHD_pool_destroy(), MHD_SCKT_FD_FITS_FDSET_, MHD_socket_close_chk_, MHD_socket_last_strerr_, MHD_strerror_, MHD_Daemon::normal_timeout_head, MHD_Daemon::normal_timeout_tail, MHD_Daemon::notify_connection_cb, MHD_Daemon::notify_connection_cb_cls, NULL, MHD_Connection::pid, MHD_Daemon::pid, MHD_Connection::pool, MHD_Connection::recv_cls, recv_param_adapter(), MHD_Connection::send_cls, send_param_adapter(), MHD_Connection::sk_nonblck, MHD_Connection::socket_fd, thread_main_handle_connection(), MHD_Daemon::thread_stack_limit_b, MHD_Daemon::threading_mode, MHD_Daemon::worker_pool, MHD_Daemon::worker_pool_size, XDLL_insert, and XDLL_remove.
Referenced by internal_add_connection(), MHD_accept_connection_(), and MHD_daemon_add_connection().
enum MHD_StatusCode MHD_accept_connection_ | ( | struct MHD_Daemon * | daemon | ) |
Accept an incoming connection and create the MHD_Connection object for it. This function also enforces policy by way of checking with the accept policy callback.
daemon | handle with the listen socket |
Definition at line 1014 of file connection_add.c.
References _, MHD_Daemon::at_limit, MHD_Daemon::cleanup_connection_mutex, MHD_Daemon::connections, fd, internal_add_connection(), MHD_Daemon::listen_socket, MAYBE_SOCK_CLOEXEC, MAYBE_SOCK_NONBLOCK, MHD_INVALID_SOCKET, MHD_mutex_lock_chk_, MHD_mutex_unlock_chk_, MHD_SCKT_EINVAL_, MHD_SCKT_ERR_IS_, MHD_SCKT_ERR_IS_DISCNN_BEFORE_ACCEPT_, MHD_SCKT_ERR_IS_EAGAIN_, MHD_SCKT_ERR_IS_LOW_RESOURCES_, MHD_socket_close_chk_, MHD_socket_get_error_, MHD_socket_last_strerr_, MHD_socket_nonblocking_(), MHD_socket_noninheritable_(), MHD_socket_strerr_, and MHD_Daemon::was_quiesced.
Referenced by internal_run_from_select().
|
static |
Callback for receiving data from the socket.
connection | the MHD connection structure |
other | where to write received data to |
i | maximum size of other (in bytes) |
Definition at line 468 of file connection_add.c.
References MHD_ERR_AGAIN_, MHD_ERR_CONNRESET_, MHD_ERR_NOTCONN_, MHD_INVALID_SOCKET, MHD_recv_, MHD_REQUEST_CLOSED, 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_Connection::request, MHD_Connection::socket_fd, and MHD_Request::state.
Referenced by internal_add_connection().
|
static |
Callback for writing data to the socket.
connection | the MHD connection structure |
other | data to write |
i | number of bytes to write |
Definition at line 521 of file connection_add.c.
References MHD_ERR_AGAIN_, MHD_ERR_CONNRESET_, MHD_ERR_NOTCONN_, MHD_INVALID_SOCKET, MHD_REQUEST_CLOSED, MHD_SCKT_ECONNRESET_, MHD_SCKT_ERR_IS_, MHD_SCKT_ERR_IS_EAGAIN_, MHD_SCKT_ERR_IS_EINTR_, MHD_SCKT_SEND_MAX_SIZE_, MHD_send_, MHD_socket_get_error_, MHD_Connection::request, MHD_Connection::socket_fd, and MHD_Request::state.
Referenced by internal_add_connection().
|
static |
Main function of the thread that handles an individual connection when MHD_USE_THREAD_PER_CONNECTION is set.
data | the struct MHD_Connection this thread will handle |
Definition at line 85 of file connection_add.c.
References _, MHD_Request::client_context, MHD_Daemon::connection_default_timeout, MHD_Connection::daemon, data, MHD_Request::event_loop_info, MHD_Daemon::event_loop_syscall, EXTRA_SLOTS, MHD_Daemon::itc, MHD_Connection::last_activity, MHD_add_to_fd_set_(), MHD_connection_call_handlers_(), MHD_connection_close_(), MHD_connection_update_last_activity_(), MHD_EVENT_LOOP_INFO_BLOCK, MHD_EVENT_LOOP_INFO_CLEANUP, MHD_EVENT_LOOP_INFO_READ, MHD_EVENT_LOOP_INFO_WRITE, MHD_INVALID_SOCKET, MHD_monotonic_sec_counter(), MHD_NO, MHD_REQUEST_CLOSED, MHD_request_handle_idle_(), MHD_request_resume(), MHD_REQUEST_TERMINATED_COMPLETED_OK, MHD_REQUEST_TERMINATED_DAEMON_SHUTDOWN, MHD_REQUEST_TERMINATED_WITH_ERROR, MHD_response_queue_for_destroy(), MHD_SCKT_EINTR_, MHD_SCKT_ERR_IS_EINTR_, MHD_SCKT_LAST_ERR_IS_, MHD_socket_get_error_, MHD_socket_last_strerr_, MHD_socket_strerr_, MHD_SYS_select_, NULL, MHD_Connection::pid, MHD_Connection::request, MHD_Request::response, MHD_Daemon::shutdown, MHD_Connection::socket_fd, MHD_Request::state, MHD_Connection::suspended, MHD_Response::termination_cb, MHD_Response::termination_cb_cls, TIMEVAL_TV_SEC_MAX, and MHD_Connection::tls_read_ready.
Referenced by internal_add_connection(), and new_connection_process_().