41#undef MHD_daemon_get_fdset
71 fd_set *except_fd_set,
83#if defined(HTTPS_SUPPORT) && defined(UPGRADE_SUPPORT)
97urh_to_fdset (
struct MHD_UpgradeResponseHandle *urh,
102 unsigned int fd_setsize)
104 const MHD_socket conn_sckt = urh->connection->socket_fd;
112 if ( (urh->in_buffer_used < urh->in_buffer_size) &&
118 if ( (0 != urh->out_buffer_used) &&
127 ((0 != urh->in_buffer_size) ||
128 (0 != urh->out_buffer_size) ||
129 (0 != urh->out_buffer_used)))
137 if ( (urh->out_buffer_used < urh->out_buffer_size) &&
143 if ( (0 != urh->in_buffer_used) &&
152 ((0 != urh->out_buffer_size) ||
153 (0 != urh->in_buffer_size) ||
154 (0 != urh->in_buffer_used)))
181static enum MHD_StatusCode
184 fd_set *write_fd_set,
185 fd_set *except_fd_set,
187 unsigned int fd_setsize)
192 enum MHD_StatusCode result = MHD_SC_OK;
196 return MHD_SC_DAEMON_ALREADY_SHUTDOWN;
205 result = MHD_SC_SOCKET_OUTSIDE_OF_FDSET_RANGE;
222 result = MHD_SC_SOCKET_OUTSIDE_OF_FDSET_RANGE;
223#ifdef MHD_POSIX_SOCKETS
235 result = MHD_SC_SOCKET_OUTSIDE_OF_FDSET_RANGE;
236#ifdef MHD_POSIX_SOCKETS
244 if ( (
NULL == except_fd_set) ||
249 result = MHD_SC_SOCKET_OUTSIDE_OF_FDSET_RANGE;
256#ifdef MHD_WINSOCK_SOCKETS
269#if defined(HTTPS_SUPPORT) && defined(UPGRADE_SUPPORT)
271 struct MHD_UpgradeResponseHandle *urh;
273 for (urh = daemon->urh_tail;
NULL != urh; urh = urh->prev)
275 if (! urh_to_fdset (urh,
281 result = MHD_SC_SOCKET_OUTSIDE_OF_FDSET_RANGE;
319 fd_set *write_fd_set,
320 fd_set *except_fd_set,
322 unsigned int fd_setsize)
326 return MHD_SC_CONFIGURATION_MISMATCH_FOR_GET_FDSET;
332 return MHD_SC_DAEMON_ALREADY_SHUTDOWN;
342 : MHD_SC_SOCKET_OUTSIDE_OF_FDSET_RANGE;
355#if defined(HTTPS_SUPPORT) && defined(UPGRADE_SUPPORT)
366urh_from_fdset (
struct MHD_UpgradeResponseHandle *urh,
371 const MHD_socket conn_sckt = urh->connection->socket_fd;
375 urh->app.celi &= (~MHD_EPOLL_STATE_READ_READY & ~MHD_EPOLL_STATE_WRITE_READY);
376 urh->mhd.celi &= (~MHD_EPOLL_STATE_READ_READY & ~MHD_EPOLL_STATE_WRITE_READY);
380 if (FD_ISSET (conn_sckt, rs))
382 if (FD_ISSET (conn_sckt, ws))
384 if (FD_ISSET (conn_sckt, es))
389 if (FD_ISSET (mhd_sckt, rs))
391 if (FD_ISSET (mhd_sckt, ws))
393 if (FD_ISSET (mhd_sckt, es))
412static enum MHD_StatusCode
414 const fd_set *read_fd_set,
415 const fd_set *write_fd_set,
416 const fd_set *except_fd_set)
421#if defined(HTTPS_SUPPORT) && defined(UPGRADE_SUPPORT)
422 struct MHD_UpgradeResponseHandle *urh;
423 struct MHD_UpgradeResponseHandle *urhn;
432 if ( (MHD_ITC_IS_VALID_ (daemon->
itc)) &&
433 (FD_ISSET (MHD_itc_r_fd_ (daemon->
itc),
435 MHD_itc_clear_ (daemon->
itc);
448 while (
NULL != (pos = prev))
464#if defined(HTTPS_SUPPORT) && defined(UPGRADE_SUPPORT)
466 for (urh = daemon->urh_tail;
NULL != urh; urh = urhn)
475 MHD_upgrade_response_handle_process_ (urh);
477 if ( (0 == urh->in_buffer_size) &&
478 (0 == urh->out_buffer_size) &&
479 (0 == urh->in_buffer_used) &&
480 (0 == urh->out_buffer_used) )
483 urh->clean_ready =
true;
494#if defined(HTTPS_SUPPORT) && defined(UPGRADE_SUPPORT)
502MHD_daemon_upgrade_connection_with_select_ (
struct MHD_Connection *con)
504 struct MHD_UpgradeResponseHandle *urh = con->
request.urh;
506 while ( (0 != urh->in_buffer_size) ||
507 (0 != urh->out_buffer_size) ||
508 (0 != urh->in_buffer_used) ||
509 (0 != urh->out_buffer_used) )
523 result = urh_to_fdset (urh,
533 MHD_SC_SOCKET_OUTSIDE_OF_FDSET_RANGE,
534 _ (
"Error preparing select.\n"));
544 (urh->in_buffer_used < urh->in_buffer_size))
568 MHD_SC_UNEXPECTED_SELECT_ERROR,
569 _ (
"Error during select (%d): `%s'\n"),
579 MHD_upgrade_response_handle_process_ (urh);
611 const fd_set *read_fd_set,
614 const fd_set *write_fd_set,
615 const fd_set *except_fd_set)
619 return MHD_SC_CONFIGURATION_MISMATCH_FOR_RUN_SELECT;
623 enum MHD_StatusCode sc;
625 sc = MHD_daemon_epoll_ (daemon,
662 struct timeval timeout;
666 enum MHD_StatusCode sc;
667 enum MHD_StatusCode sc2;
672 return MHD_SC_DAEMON_ALREADY_SHUTDOWN;
698 _ (
"Could not obtain daemon fdsets.\n"));
714 MHD_SC_SOCKET_OUTSIDE_OF_FDSET_RANGE,
715 _ (
"Could not add listen socket to fdset.\n"));
717 return MHD_SC_SOCKET_OUTSIDE_OF_FDSET_RANGE;
720 if ( (MHD_ITC_IS_VALID_ (daemon->
itc)) &&
726#if defined(MHD_WINSOCK_SOCKETS)
741 sc = MHD_SC_SOCKET_OUTSIDE_OF_FDSET_RANGE;
746 "Could not add control inter-thread communication channel FD to fdset.\n"));
748#if defined(MHD_WINSOCK_SOCKETS)
762 (MHD_ITC_IS_VALID_ (daemon->
itc)) &&
778 else if ( (MHD_TM_THREAD_PER_CONNECTION != daemon->
threading_mode) &&
784 timeout.tv_usec = (ltimeout % 1000) * 1000;
797 return MHD_SC_DAEMON_ALREADY_SHUTDOWN;
806 MHD_SC_UNEXPECTED_SELECT_ERROR,
807 _ (
"select failed: %s\n"),
810 return MHD_SC_UNEXPECTED_SELECT_ERROR;
#define MHD_connection_finish_forward_(conn)
enum MHD_StatusCode MHD_accept_connection_(struct MHD_Daemon *daemon)
functions to add connection to our active set
int MHD_connection_call_handlers_(struct MHD_Connection *con, bool read_ready, bool write_ready, bool force_close)
function to call event handlers based on event mask
void MHD_connection_cleanup_(struct MHD_Daemon *daemon)
functions to cleanup completed connection
complete upgrade socket forwarding operation in TLS mode
non-public functions provided by daemon_epoll.c
enum MHD_StatusCode MHD_daemon_select_(struct MHD_Daemon *daemon, int may_block)
non-public functions provided by daemon_select.c
enum MHD_StatusCode MHD_daemon_get_timeout(struct MHD_Daemon *daemon, MHD_UNSIGNED_LONG_LONG *timeout)
static enum MHD_StatusCode internal_get_fdset2(struct MHD_Daemon *daemon, fd_set *read_fd_set, fd_set *write_fd_set, fd_set *except_fd_set, MHD_socket *max_fd, unsigned int fd_setsize)
enum MHD_StatusCode MHD_daemon_run_from_select(struct MHD_Daemon *daemon, const fd_set *read_fd_set, const fd_set *write_fd_set, const fd_set *except_fd_set)
enum MHD_StatusCode MHD_daemon_get_fdset2(struct MHD_Daemon *daemon, fd_set *read_fd_set, fd_set *write_fd_set, fd_set *except_fd_set, MHD_socket *max_fd, unsigned int fd_setsize)
enum MHD_StatusCode MHD_daemon_get_fdset(struct MHD_Daemon *daemon, fd_set *read_fd_set, fd_set *write_fd_set, fd_set *except_fd_set, MHD_socket *max_fd)
static enum MHD_StatusCode internal_run_from_select(struct MHD_Daemon *daemon, const fd_set *read_fd_set, const fd_set *write_fd_set, const fd_set *except_fd_set)
@ MHD_EPOLL_STATE_READ_READY
@ MHD_EPOLL_STATE_WRITE_READY
#define TIMEVAL_TV_SEC_MAX
int MHD_add_to_fd_set_(MHD_socket fd, fd_set *set, MHD_socket *max_fd, unsigned int fd_setsize)
#define _MHD_SYS_DEFAULT_FD_SETSIZE
#define MHD_socket_strerr_(err)
#define MHD_socket_get_error_()
#define MHD_SCKT_ERR_IS_EINTR_(err)
#define MHD_SYS_select_(n, r, w, e, t)
MHD internal shared structures.
@ MHD_EVENT_LOOP_INFO_READ
@ MHD_EVENT_LOOP_INFO_WRITE
@ MHD_EVENT_LOOP_INFO_CLEANUP
@ MHD_EVENT_LOOP_INFO_BLOCK
#define MHD_UNSIGNED_LONG_LONG
#define MHD_INVALID_SOCKET
void MHD_request_resume(struct MHD_Request *request)
bool MHD_resume_suspended_connections_(struct MHD_Daemon *daemon)
implementation of MHD_request_resume()
struct MHD_Request request
struct MHD_Connection * prev
struct MHD_Daemon * daemon
bool data_already_pending
enum MHD_EventLoopSyscall event_loop_syscall
bool disallow_suspend_resume
enum MHD_ThreadingMode threading_mode
unsigned int global_connection_limit
struct MHD_Connection * connections_tail
enum MHD_RequestEventLoopInfo event_loop_info
function to process upgrade activity (over TLS)