41 #undef MHD_daemon_get_fdset 71 fd_set *except_fd_set,
83 #if defined(HTTPS_SUPPORT) && defined(UPGRADE_SUPPORT) 97 urh_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)))
179 static enum MHD_StatusCode
182 fd_set *write_fd_set,
183 fd_set *except_fd_set,
185 unsigned int fd_setsize)
190 enum MHD_StatusCode result = MHD_SC_OK;
194 return MHD_SC_DAEMON_ALREADY_SHUTDOWN;
203 result = MHD_SC_SOCKET_OUTSIDE_OF_FDSET_RANGE;
220 result = MHD_SC_SOCKET_OUTSIDE_OF_FDSET_RANGE;
221 #ifdef MHD_POSIX_SOCKETS 233 result = MHD_SC_SOCKET_OUTSIDE_OF_FDSET_RANGE;
234 #ifdef MHD_POSIX_SOCKETS 242 if ( (
NULL == except_fd_set) ||
247 result = MHD_SC_SOCKET_OUTSIDE_OF_FDSET_RANGE;
254 #ifdef MHD_WINSOCK_SOCKETS 267 #if defined(HTTPS_SUPPORT) && defined(UPGRADE_SUPPORT) 269 struct MHD_UpgradeResponseHandle *urh;
271 for (urh = daemon->urh_tail;
NULL != urh; urh = urh->prev)
273 if (! urh_to_fdset (urh,
279 result = MHD_SC_SOCKET_OUTSIDE_OF_FDSET_RANGE;
317 fd_set *write_fd_set,
318 fd_set *except_fd_set,
320 unsigned int fd_setsize)
324 return MHD_SC_CONFIGURATION_MISMATCH_FOR_GET_FDSET;
330 return MHD_SC_DAEMON_ALREADY_SHUTDOWN;
340 : MHD_SC_SOCKET_OUTSIDE_OF_FDSET_RANGE;
353 #if defined(HTTPS_SUPPORT) && defined(UPGRADE_SUPPORT) 364 urh_from_fdset (
struct MHD_UpgradeResponseHandle *urh,
369 const MHD_socket conn_sckt = urh->connection->socket_fd;
378 if (FD_ISSET (conn_sckt, rs))
380 if (FD_ISSET (conn_sckt, ws))
382 if (FD_ISSET (conn_sckt, es))
387 if (FD_ISSET (mhd_sckt, rs))
389 if (FD_ISSET (mhd_sckt, ws))
391 if (FD_ISSET (mhd_sckt, es))
408 static enum MHD_StatusCode
410 const fd_set *read_fd_set,
411 const fd_set *write_fd_set,
412 const fd_set *except_fd_set)
417 #if defined(HTTPS_SUPPORT) && defined(UPGRADE_SUPPORT) 418 struct MHD_UpgradeResponseHandle *urh;
419 struct MHD_UpgradeResponseHandle *urhn;
428 if ( (MHD_ITC_IS_VALID_(daemon->
itc)) &&
429 (FD_ISSET (MHD_itc_r_fd_ (daemon->
itc),
431 MHD_itc_clear_ (daemon->
itc);
444 while (
NULL != (pos = prev))
460 #if defined(HTTPS_SUPPORT) && defined(UPGRADE_SUPPORT) 462 for (urh = daemon->urh_tail;
NULL != urh; urh = urhn)
471 MHD_upgrade_response_handle_process_ (urh);
473 if ( (0 == urh->in_buffer_size) &&
474 (0 == urh->out_buffer_size) &&
475 (0 == urh->in_buffer_used) &&
476 (0 == urh->out_buffer_used) )
479 urh->clean_ready =
true;
490 #if defined(HTTPS_SUPPORT) && defined(UPGRADE_SUPPORT) 498 MHD_daemon_upgrade_connection_with_select_ (
struct MHD_Connection *con)
500 struct MHD_UpgradeResponseHandle *urh = con->
request.urh;
502 while ( (0 != urh->in_buffer_size) ||
503 (0 != urh->out_buffer_size) ||
504 (0 != urh->in_buffer_used) ||
505 (0 != urh->out_buffer_used) )
519 result = urh_to_fdset (urh,
529 MHD_SC_SOCKET_OUTSIDE_OF_FDSET_RANGE,
530 _(
"Error preparing select\n"));
540 (urh->in_buffer_used < urh->in_buffer_size))
564 MHD_SC_UNEXPECTED_SELECT_ERROR,
565 _(
"Error during select (%d): `%s'\n"),
575 MHD_upgrade_response_handle_process_ (urh);
605 const fd_set *read_fd_set,
608 const fd_set *write_fd_set,
609 const fd_set *except_fd_set)
613 return MHD_SC_CONFIGURATION_MISSMATCH_FOR_RUN_SELECT;
617 enum MHD_StatusCode sc;
619 sc = MHD_daemon_epoll_ (daemon,
656 struct timeval timeout;
660 enum MHD_StatusCode sc;
661 enum MHD_StatusCode sc2;
666 return MHD_SC_DAEMON_ALREADY_SHUTDOWN;
692 _(
"Could not obtain daemon fdsets"));
708 MHD_SC_SOCKET_OUTSIDE_OF_FDSET_RANGE,
709 _(
"Could not add listen socket to fdset"));
711 return MHD_SC_SOCKET_OUTSIDE_OF_FDSET_RANGE;
714 if ( (MHD_ITC_IS_VALID_(daemon->
itc)) &&
720 #if defined(MHD_WINSOCK_SOCKETS) 735 sc = MHD_SC_SOCKET_OUTSIDE_OF_FDSET_RANGE;
739 _(
"Could not add control inter-thread communication channel FD to fdset"));
741 #if defined(MHD_WINSOCK_SOCKETS) 753 (MHD_ITC_IS_VALID_(daemon->
itc)) &&
769 else if ( (MHD_TM_THREAD_PER_CONNECTION != daemon->
threading_mode) &&
775 timeout.tv_usec = (ltimeout % 1000) * 1000;
788 return MHD_SC_DAEMON_ALREADY_SHUTDOWN;
797 MHD_SC_UNEXPECTED_SELECT_ERROR,
798 _(
"select failed: %s\n"),
801 return MHD_SC_UNEXPECTED_SELECT_ERROR;
struct MHD_Request request
enum MHD_EventLoopSyscall event_loop_syscall
bool data_already_pending
#define MHD_SYS_select_(n, r, w, e, t)
non-public functions provided by daemon_select.c
unsigned int global_connection_limit
#define MHD_socket_get_error_()
#define MHD_socket_strerr_(err)
enum MHD_StatusCode MHD_daemon_select_(struct MHD_Daemon *daemon, int may_block)
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)
int MHD_add_to_fd_set_(MHD_socket fd, fd_set *set, MHD_socket *max_fd, unsigned int fd_setsize)
non-public functions provided by daemon_epoll.c
internal shared structures
#define MHD_UNSIGNED_LONG_LONG
struct MHD_Daemon * daemon
struct MHD_Connection * connections_tail
enum MHD_StatusCode MHD_daemon_get_timeout(struct MHD_Daemon *daemon, MHD_UNSIGNED_LONG_LONG *timeout)
#define MHD_INVALID_SOCKET
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)
complete upgrade socket forwarding operation in TLS mode
enum MHD_RequestEventLoopInfo event_loop_info
function to call event handlers based on event mask
enum MHD_StatusCode MHD_accept_connection_(struct MHD_Daemon *daemon)
functions to cleanup completed connection
struct MHD_Connection * prev
#define TIMEVAL_TV_SEC_MAX
#define _MHD_SYS_DEFAULT_FD_SETSIZE
int MHD_connection_call_handlers_(struct MHD_Connection *con, bool read_ready, bool write_ready, bool force_close)
void MHD_request_resume(struct MHD_Request *request)
void MHD_connection_finish_forward_(struct MHD_Connection *connection) MHD_NONNULL(1)
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)
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)
void MHD_connection_cleanup_(struct MHD_Daemon *daemon)
bool disallow_suspend_resume
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)
bool MHD_resume_suspended_connections_(struct MHD_Daemon *daemon)
enum MHD_ThreadingMode threading_mode
#define MHD_SCKT_ERR_IS_EINTR_(err)
function to process upgrade activity (over TLS)
functions to add connection to our active set
implementation of MHD_request_resume()