diff options
author | Evgeny Grin (Karlson2k) <k2k@narod.ru> | 2016-10-24 15:18:26 +0300 |
---|---|---|
committer | Evgeny Grin (Karlson2k) <k2k@narod.ru> | 2016-11-01 20:51:01 +0300 |
commit | 384cb2ab655970311ef89993810f7b62ad55b189 (patch) | |
tree | 2ca0d63f40e816aa7d2b198b29fc340875d073d8 /src/microhttpd/connection_https.c | |
parent | 47f1d52e799227322c83d3114d3a6b7b54d2e5dd (diff) | |
download | libmicrohttpd-384cb2ab655970311ef89993810f7b62ad55b189.tar.gz libmicrohttpd-384cb2ab655970311ef89993810f7b62ad55b189.zip |
Deduplicated connection's closure code, improved TLS closure.
Diffstat (limited to 'src/microhttpd/connection_https.c')
-rw-r--r-- | src/microhttpd/connection_https.c | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/src/microhttpd/connection_https.c b/src/microhttpd/connection_https.c index bbfebd22..f1f1f90c 100644 --- a/src/microhttpd/connection_https.c +++ b/src/microhttpd/connection_https.c | |||
@@ -152,8 +152,6 @@ MHD_tls_connection_handle_idle (struct MHD_Connection *connection) | |||
152 | break; | 152 | break; |
153 | /* close connection if necessary */ | 153 | /* close connection if necessary */ |
154 | case MHD_CONNECTION_CLOSED: | 154 | case MHD_CONNECTION_CLOSED: |
155 | gnutls_bye (connection->tls_session, | ||
156 | GNUTLS_SHUT_RDWR); | ||
157 | return MHD_connection_handle_idle (connection); | 155 | return MHD_connection_handle_idle (connection); |
158 | default: | 156 | default: |
159 | if ( (0 != gnutls_record_check_pending (connection->tls_session)) && | 157 | if ( (0 != gnutls_record_check_pending (connection->tls_session)) && |
@@ -183,4 +181,22 @@ MHD_set_https_callbacks (struct MHD_Connection *connection) | |||
183 | connection->idle_handler = &MHD_tls_connection_handle_idle; | 181 | connection->idle_handler = &MHD_tls_connection_handle_idle; |
184 | } | 182 | } |
185 | 183 | ||
184 | |||
185 | /** | ||
186 | * Initiate shutdown of TLS layer of connection. | ||
187 | * | ||
188 | * @param connection to use | ||
189 | * @return #MHD_YES if succeed, #MHD_NO otherwise. | ||
190 | */ | ||
191 | int | ||
192 | MHD_tls_connection_shutdown (struct MHD_Connection *connection) | ||
193 | { | ||
194 | if (MHD_NO != connection->tls_closed) | ||
195 | return MHD_NO; | ||
196 | |||
197 | connection->tls_closed = MHD_YES; | ||
198 | return (GNUTLS_E_SUCCESS == gnutls_bye(connection->tls_session, GNUTLS_SHUT_WR)) ? | ||
199 | MHD_YES : MHD_NO; | ||
200 | } | ||
201 | |||
186 | /* end of connection_https.c */ | 202 | /* end of connection_https.c */ |