Merged MHD_tls_connection_handle_read() into MHD_connection_handle_read()

This commit is contained in:
Evgeny Grin (Karlson2k)
2017-06-05 23:01:56 +03:00
parent 1d356a1f48
commit de669ead80
5 changed files with 28 additions and 40 deletions
+11 -1
View File
@@ -2667,6 +2667,17 @@ MHD_connection_handle_read (struct MHD_Connection *connection)
if ( (MHD_CONNECTION_CLOSED == connection->state) ||
(connection->suspended) )
return MHD_YES;
#ifdef HTTPS_SUPPORT
if (MHD_TLS_CONN_NO_TLS != connection->tls_state)
{ /* HTTPS connection. */
if (MHD_TLS_CONN_CONNECTED > connection->tls_state)
{
if (!MHD_run_tls_handshake_ (connection))
return MHD_YES;
}
}
#endif /* HTTPS_SUPPORT */
/* make sure "read" has a reasonable number of bytes
in buffer to use per system call (if possible) */
if (connection->read_buffer_offset + connection->daemon->pool_increment >
@@ -3624,7 +3635,6 @@ MHD_connection_epoll_update_ (struct MHD_Connection *connection)
void
MHD_set_http_callbacks_ (struct MHD_Connection *connection)
{
connection->read_handler = &MHD_connection_handle_read;
connection->write_handler = &MHD_connection_handle_write;
connection->recv_cls = &recv_param_adapter;
connection->send_cls = &send_param_adapter;
+3 -32
View File
@@ -143,8 +143,8 @@ send_tls_adapter (struct MHD_Connection *connection,
* false is handshake in progress or in case
* of error
*/
static bool
run_tls_handshake (struct MHD_Connection *connection)
bool
MHD_run_tls_handshake_ (struct MHD_Connection *connection)
{
int ret;
@@ -180,34 +180,6 @@ run_tls_handshake (struct MHD_Connection *connection)
}
/**
* This function handles a particular SSL/TLS connection when
* it has been determined that there is data to be read off a
* socket. Message processing is done by message type which is
* determined by peeking into the first message type byte of the
* stream.
*
* Error message handling: all fatal level messages cause the
* connection to be terminated.
*
* Application data is forwarded to the underlying daemon for
* processing.
*
* @param connection the source connection
* @return always #MHD_YES (we should continue to process the connection)
*/
static int
MHD_tls_connection_handle_read (struct MHD_Connection *connection)
{
if (MHD_TLS_CONN_CONNECTED > connection->tls_state)
{
if (!run_tls_handshake(connection))
return MHD_YES;
}
return MHD_connection_handle_read (connection);
}
/**
* This function was created to handle writes to sockets when it has
* been determined that the socket can be written to. This function
@@ -221,7 +193,7 @@ MHD_tls_connection_handle_write (struct MHD_Connection *connection)
{
if (MHD_TLS_CONN_CONNECTED > connection->tls_state)
{
if (!run_tls_handshake(connection))
if (!MHD_run_tls_handshake_(connection))
return MHD_YES;
}
return MHD_connection_handle_write (connection);
@@ -237,7 +209,6 @@ MHD_tls_connection_handle_write (struct MHD_Connection *connection)
void
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->recv_cls = &recv_tls_adapter;
connection->send_cls = &send_tls_adapter;
+13
View File
@@ -39,6 +39,19 @@ void
MHD_set_https_callbacks (struct MHD_Connection *connection);
/**
* Give gnuTLS chance to work on the TLS handshake.
*
* @param connection connection to handshake on
* @return true if the handshake has completed successfully
* and we should start to read/write data,
* false is handshake in progress or in case
* of error
*/
bool
MHD_run_tls_handshake_ (struct MHD_Connection *connection);
/**
* Initiate shutdown of TLS layer of connection.
*
+1 -1
View File
@@ -1043,7 +1043,7 @@ call_handlers (struct MHD_Connection *con,
if ( (MHD_EVENT_LOOP_INFO_READ == con->event_loop_info) &&
read_ready)
{
con->read_handler (con);
MHD_connection_handle_read (con);
ret = MHD_connection_handle_idle (con);
states_info_processed = true;
}
-6
View File
@@ -930,12 +930,6 @@ struct MHD_Connection
*/
uint64_t current_chunk_offset;
/**
* Handler used for processing read connection operations
* @sa #MHD_connection_handle_read, #MHD_tls_connection_handle_read
*/
int (*read_handler) (struct MHD_Connection *connection);
/**
* Handler used for processing write connection operations
* @sa #MHD_connection_handle_write, #MHD_tls_connection_handle_write