aboutsummaryrefslogtreecommitdiff
path: root/src/microhttpd/connection.c
diff options
context:
space:
mode:
authorEvgeny Grin (Karlson2k) <k2k@narod.ru>2017-06-05 20:39:26 +0300
committerEvgeny Grin (Karlson2k) <k2k@narod.ru>2017-06-05 22:09:53 +0300
commit243e8fcd6054e4c0d2964b0d4b29e0c15861498d (patch)
tree3a65f86811ce466d2e88a45cfba43bb0fd06732e /src/microhttpd/connection.c
parent1b71798df8b8341b894dfc6223d01bd1cb8e83bd (diff)
downloadlibmicrohttpd-243e8fcd6054e4c0d2964b0d4b29e0c15861498d.tar.gz
libmicrohttpd-243e8fcd6054e4c0d2964b0d4b29e0c15861498d.zip
Used separate 'state' for TLS layer (independent of state of HTTP process)
Diffstat (limited to 'src/microhttpd/connection.c')
-rw-r--r--src/microhttpd/connection.c42
1 files changed, 27 insertions, 15 deletions
diff --git a/src/microhttpd/connection.c b/src/microhttpd/connection.c
index 21fe9aac..cd8b5b04 100644
--- a/src/microhttpd/connection.c
+++ b/src/microhttpd/connection.c
@@ -1648,6 +1648,25 @@ MHD_connection_update_event_loop_info (struct MHD_Connection *connection)
1648 /* Do not update states of suspended connection */ 1648 /* Do not update states of suspended connection */
1649 if (connection->suspended) 1649 if (connection->suspended)
1650 return; /* States will be updated after resume. */ 1650 return; /* States will be updated after resume. */
1651#ifdef HTTPS_SUPPORT
1652 if (MHD_TLS_CONN_NO_TLS != connection->tls_state)
1653 { /* HTTPS connection. */
1654 switch (connection->tls_state)
1655 {
1656 case MHD_TLS_CONN_INIT:
1657 connection->event_loop_info = MHD_EVENT_LOOP_INFO_READ;
1658 return;
1659 case MHD_TLS_CONN_HANDSHAKING:
1660 if (0 == gnutls_record_get_direction (connection->tls_session))
1661 connection->event_loop_info = MHD_EVENT_LOOP_INFO_READ;
1662 else
1663 connection->event_loop_info = MHD_EVENT_LOOP_INFO_WRITE;
1664 return;
1665 default:
1666 break;
1667 }
1668 }
1669#endif /* HTTPS_SUPPORT */
1651 while (1) 1670 while (1)
1652 { 1671 {
1653#if DEBUG_STATES 1672#if DEBUG_STATES
@@ -1658,14 +1677,6 @@ MHD_connection_update_event_loop_info (struct MHD_Connection *connection)
1658#endif 1677#endif
1659 switch (connection->state) 1678 switch (connection->state)
1660 { 1679 {
1661#ifdef HTTPS_SUPPORT
1662 case MHD_TLS_CONNECTION_INIT:
1663 if (0 == gnutls_record_get_direction (connection->tls_session))
1664 connection->event_loop_info = MHD_EVENT_LOOP_INFO_READ;
1665 else
1666 connection->event_loop_info = MHD_EVENT_LOOP_INFO_WRITE;
1667 break;
1668#endif /* HTTPS_SUPPORT */
1669 case MHD_CONNECTION_INIT: 1680 case MHD_CONNECTION_INIT:
1670 case MHD_CONNECTION_URL_RECEIVED: 1681 case MHD_CONNECTION_URL_RECEIVED:
1671 case MHD_CONNECTION_HEADER_PART_RECEIVED: 1682 case MHD_CONNECTION_HEADER_PART_RECEIVED:
@@ -2959,9 +2970,6 @@ MHD_connection_handle_write (struct MHD_Connection *connection)
2959 break; 2970 break;
2960 case MHD_CONNECTION_CLOSED: 2971 case MHD_CONNECTION_CLOSED:
2961 return MHD_YES; 2972 return MHD_YES;
2962 case MHD_TLS_CONNECTION_INIT:
2963 EXTRA_CHECK (0);
2964 break;
2965 case MHD_CONNECTION_IN_CLEANUP: 2973 case MHD_CONNECTION_IN_CLEANUP:
2966 EXTRA_CHECK (0); 2974 EXTRA_CHECK (0);
2967 break; 2975 break;
@@ -3072,6 +3080,14 @@ MHD_connection_handle_idle (struct MHD_Connection *connection)
3072 connection->in_idle = true; 3080 connection->in_idle = true;
3073 while (! connection->suspended) 3081 while (! connection->suspended)
3074 { 3082 {
3083#ifdef HTTPS_SUPPORT
3084 if (MHD_TLS_CONN_NO_TLS != connection->tls_state)
3085 { /* HTTPS connection. */
3086 if ((MHD_TLS_CONN_INIT <= connection->tls_state) &&
3087 (MHD_TLS_CONN_CONNECTED > connection->tls_state))
3088 break;
3089 }
3090#endif /* HTTPS_SUPPORT */
3075#if DEBUG_STATES 3091#if DEBUG_STATES
3076 MHD_DLOG (daemon, 3092 MHD_DLOG (daemon,
3077 _("In function %s handling connection at state: %s\n"), 3093 _("In function %s handling connection at state: %s\n"),
@@ -3080,10 +3096,6 @@ MHD_connection_handle_idle (struct MHD_Connection *connection)
3080#endif 3096#endif
3081 switch (connection->state) 3097 switch (connection->state)
3082 { 3098 {
3083#ifdef HTTPS_SUPPORT
3084 case MHD_TLS_CONNECTION_INIT:
3085 break;
3086#endif /* HTTPS_SUPPORT */
3087 case MHD_CONNECTION_INIT: 3099 case MHD_CONNECTION_INIT:
3088 line = get_next_header_line (connection, 3100 line = get_next_header_line (connection,
3089 &line_len); 3101 &line_len);