mirror of
https://git.gnunet.org/libmicrohttpd.git
synced 2026-09-27 04:09:31 +03:00
Removed MHD_tls_connection_handle_idle() and MHD_Connection::idle_handler.
Ensure that MHD_connection_update_event_loop_info() is called for MHD_TLS_CONNECTION_INIT state to properly update read/write event loop info when doing TLS handshake
This commit is contained in:
@@ -2910,6 +2910,10 @@ MHD_connection_handle_idle (struct MHD_Connection *connection)
|
||||
#endif
|
||||
switch (connection->state)
|
||||
{
|
||||
#ifdef HTTPS_SUPPORT
|
||||
case MHD_TLS_CONNECTION_INIT:
|
||||
break;
|
||||
#endif /* HTTPS_SUPPORT */
|
||||
case MHD_CONNECTION_INIT:
|
||||
line = get_next_header_line (connection,
|
||||
&line_len);
|
||||
@@ -3441,7 +3445,6 @@ MHD_set_http_callbacks_ (struct MHD_Connection *connection)
|
||||
{
|
||||
connection->read_handler = &MHD_connection_handle_read;
|
||||
connection->write_handler = &MHD_connection_handle_write;
|
||||
connection->idle_handler = &MHD_connection_handle_idle;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -119,53 +119,6 @@ MHD_tls_connection_handle_write (struct MHD_Connection *connection)
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* This function was created to handle per-connection processing that
|
||||
* has to happen even if the socket cannot be read or written to. All
|
||||
* implementations (multithreaded, external select, internal select)
|
||||
* call this function.
|
||||
*
|
||||
* @param connection being handled
|
||||
* @return #MHD_YES if we should continue to process the
|
||||
* connection (not dead yet), #MHD_NO if it died
|
||||
*/
|
||||
static int
|
||||
MHD_tls_connection_handle_idle (struct MHD_Connection *connection)
|
||||
{
|
||||
time_t timeout;
|
||||
|
||||
#if DEBUG_STATES
|
||||
MHD_DLOG (connection->daemon,
|
||||
_("In function %s handling connection at state: %s\n"),
|
||||
__FUNCTION__,
|
||||
MHD_state_to_string (connection->state));
|
||||
#endif
|
||||
if (connection->suspended)
|
||||
return MHD_connection_handle_idle (connection);
|
||||
switch (connection->state)
|
||||
{
|
||||
/* on newly created connections we might reach here before any reply has been received */
|
||||
case MHD_TLS_CONNECTION_INIT:
|
||||
break;
|
||||
/* close connection if necessary */
|
||||
case MHD_CONNECTION_CLOSED:
|
||||
return MHD_connection_handle_idle (connection);
|
||||
default:
|
||||
return MHD_connection_handle_idle (connection);
|
||||
}
|
||||
timeout = connection->connection_timeout;
|
||||
if ( (timeout != 0) &&
|
||||
(timeout < (MHD_monotonic_sec_counter() - connection->last_activity)))
|
||||
MHD_connection_close_ (connection,
|
||||
MHD_REQUEST_TERMINATED_TIMEOUT_REACHED);
|
||||
#ifdef EPOLL_SUPPORT
|
||||
return MHD_connection_epoll_update_ (connection);
|
||||
#else
|
||||
return MHD_YES;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set connection callback function to be used through out
|
||||
* the processing of this secure connection.
|
||||
@@ -177,7 +130,6 @@ MHD_set_https_callbacks (struct MHD_Connection *connection)
|
||||
{
|
||||
connection->read_handler = &MHD_tls_connection_handle_read;
|
||||
connection->write_handler = &MHD_tls_connection_handle_write;
|
||||
connection->idle_handler = &MHD_tls_connection_handle_idle;
|
||||
}
|
||||
|
||||
|
||||
|
||||
+13
-13
@@ -1151,7 +1151,7 @@ call_handlers (struct MHD_Connection *con,
|
||||
read_ready)
|
||||
{
|
||||
con->read_handler (con);
|
||||
ret = con->idle_handler (con);
|
||||
ret = MHD_connection_handle_idle (con);
|
||||
states_info_processed = true;
|
||||
}
|
||||
/* No need to check value of 'ret' here as closed connection
|
||||
@@ -1160,7 +1160,7 @@ call_handlers (struct MHD_Connection *con,
|
||||
write_ready)
|
||||
{
|
||||
con->write_handler (con);
|
||||
ret = con->idle_handler (con);
|
||||
ret = MHD_connection_handle_idle (con);
|
||||
states_info_processed = true;
|
||||
}
|
||||
}
|
||||
@@ -1168,17 +1168,17 @@ call_handlers (struct MHD_Connection *con,
|
||||
{
|
||||
MHD_connection_close_ (con,
|
||||
MHD_REQUEST_TERMINATED_WITH_ERROR);
|
||||
return con->idle_handler (con);
|
||||
return MHD_connection_handle_idle (con);
|
||||
}
|
||||
|
||||
if (!states_info_processed)
|
||||
{ /* Connection is not read or write ready, but external conditions
|
||||
* may be changed and need to be processed. */
|
||||
ret = con->idle_handler (con);
|
||||
ret = MHD_connection_handle_idle (con);
|
||||
}
|
||||
/* Fast track for fast connections. */
|
||||
/* If full request was read by single read_handler() invocation
|
||||
and headers were completely prepared by single idle_handler()
|
||||
and headers were completely prepared by single MHD_connection_handle_idle()
|
||||
then try not to wait for next sockets polling and send response
|
||||
immediately.
|
||||
As writeability of socket was not checked and it may have
|
||||
@@ -1191,17 +1191,17 @@ call_handlers (struct MHD_Connection *con,
|
||||
if (MHD_CONNECTION_HEADERS_SENDING == con->state)
|
||||
{
|
||||
con->write_handler (con);
|
||||
/* Always call 'idle_handler()' after each read/write. */
|
||||
ret = con->idle_handler (con);
|
||||
/* Always call 'MHD_connection_handle_idle()' after each read/write. */
|
||||
ret = MHD_connection_handle_idle (con);
|
||||
}
|
||||
/* If all headers were sent by single write_handler() and
|
||||
* response body is prepared by single idle_handler()
|
||||
* response body is prepared by single MHD_connection_handle_idle()
|
||||
* call - continue. */
|
||||
if ((MHD_CONNECTION_NORMAL_BODY_READY == con->state) ||
|
||||
(MHD_CONNECTION_CHUNKED_BODY_READY == con->state))
|
||||
{
|
||||
con->write_handler (con);
|
||||
ret = con->idle_handler (con);
|
||||
ret = MHD_connection_handle_idle (con);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2118,7 +2118,7 @@ thread_main_handle_connection (void *data)
|
||||
(daemon->shutdown) ?
|
||||
MHD_REQUEST_TERMINATED_DAEMON_SHUTDOWN:
|
||||
MHD_REQUEST_TERMINATED_WITH_ERROR);
|
||||
con->idle_handler (con);
|
||||
MHD_connection_handle_idle (con);
|
||||
}
|
||||
exit:
|
||||
if (NULL != con->response)
|
||||
@@ -4428,7 +4428,7 @@ MHD_epoll (struct MHD_Daemon *daemon,
|
||||
}
|
||||
|
||||
/* Finally, handle timed-out connections; we need to do this here
|
||||
as the epoll mechanism won't call the 'idle_handler' on everything,
|
||||
as the epoll mechanism won't call the 'MHD_connection_handle_idle()' on everything,
|
||||
as the other event loops do. As timeouts do not get an explicit
|
||||
event, we need to find those connections that might have timed out
|
||||
here.
|
||||
@@ -4439,7 +4439,7 @@ MHD_epoll (struct MHD_Daemon *daemon,
|
||||
while (NULL != (pos = prev))
|
||||
{
|
||||
prev = pos->prevX;
|
||||
pos->idle_handler (pos);
|
||||
MHD_connection_handle_idle (pos);
|
||||
}
|
||||
/* Connections with the default timeout are sorted by prepending
|
||||
them to the head of the list whenever we touch the connection;
|
||||
@@ -4449,7 +4449,7 @@ MHD_epoll (struct MHD_Daemon *daemon,
|
||||
while (NULL != (pos = prev))
|
||||
{
|
||||
prev = pos->prevX;
|
||||
pos->idle_handler (pos);
|
||||
MHD_connection_handle_idle (pos);
|
||||
if (MHD_CONNECTION_CLOSED != pos->state)
|
||||
break; /* sorted by timeout, no need to visit the rest! */
|
||||
}
|
||||
|
||||
@@ -935,12 +935,6 @@ struct MHD_Connection
|
||||
*/
|
||||
int (*write_handler) (struct MHD_Connection *connection);
|
||||
|
||||
/**
|
||||
* Handler used for processing idle connection operations
|
||||
* @sa #MHD_connection_handle_idle, #MHD_tls_connection_handle_idle
|
||||
*/
|
||||
int (*idle_handler) (struct MHD_Connection *connection);
|
||||
|
||||
/**
|
||||
* Function used for reading HTTP request stream.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user