[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] [libmicrohttpd] 03/03: run_tls_handshake(): refactoring: re
From: |
gnunet |
Subject: |
[GNUnet-SVN] [libmicrohttpd] 03/03: run_tls_handshake(): refactoring: return false if data send is not (yet) allowed |
Date: |
Mon, 05 Jun 2017 21:21:54 +0200 |
This is an automated email from the git hooks/post-receive script.
karlson2k pushed a commit to branch master
in repository libmicrohttpd.
commit 35be224f8cf3649941f33fc16104ce7c3b459a92
Author: Evgeny Grin (Karlson2k) <address@hidden>
AuthorDate: Mon Jun 5 22:09:15 2017 +0300
run_tls_handshake(): refactoring: return false if data send is not (yet)
allowed
---
ChangeLog | 12 ++++++++++++
src/microhttpd/connection_https.c | 31 +++++++++++++++++++------------
2 files changed, 31 insertions(+), 12 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 657dc286..7d44bd2b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,15 @@
+Mon Jun 05 22:20:00 MSK 2017
+ Internal refactoring:
+ used TCP sockets directly with GnuTLS (performance improvement),
+ moved some connection-related code from daemon.c to
+ connection.c/connection_https.c,
+ removed hacks around sendfile() and implemented correct support of
+ sendfile(),
+ removed do_read() and do_write() to reduce number of layer around send()
+ and recv() and to improve readability and maintainability of code,
+ implemented separate tracking of TLS layer state, independent of HTTP
+ connection stage. -EG
+
Sun Jun 04 15:02:00 MSK 2017
Improved thread-safety of MHD_add_connection() and
internal_add_connection(), minor optimisations. -EG
diff --git a/src/microhttpd/connection_https.c
b/src/microhttpd/connection_https.c
index 9fe62b08..d345b9aa 100644
--- a/src/microhttpd/connection_https.c
+++ b/src/microhttpd/connection_https.c
@@ -138,11 +138,12 @@ send_tls_adapter (struct MHD_Connection *connection,
* Give gnuTLS chance to work on the TLS handshake.
*
* @param connection connection to handshake on
- * @return #MHD_YES on error or if the handshake is progressing
- * #MHD_NO if the handshake has completed successfully
- * and we should start to read/write data
+ * @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
*/
-static int
+static bool
run_tls_handshake (struct MHD_Connection *connection)
{
int ret;
@@ -156,14 +157,14 @@ run_tls_handshake (struct MHD_Connection *connection)
/* set connection TLS state to enable HTTP processing */
connection->tls_state = MHD_TLS_CONN_CONNECTED;
MHD_update_last_activity_ (connection);
- return MHD_NO;
+ return true;
}
if ( (GNUTLS_E_AGAIN == ret) ||
(GNUTLS_E_INTERRUPTED == ret) )
{
connection->tls_state = MHD_TLS_CONN_HANDSHAKING;
/* handshake not done */
- return MHD_YES;
+ return false;
}
/* handshake failed */
connection->tls_state = MHD_TLS_CONN_TLS_FAILED;
@@ -173,9 +174,9 @@ run_tls_handshake (struct MHD_Connection *connection)
#endif
MHD_connection_close_ (connection,
MHD_REQUEST_TERMINATED_WITH_ERROR);
- return MHD_YES;
+ return false;
}
- return MHD_NO;
+ return true;
}
@@ -198,8 +199,11 @@ run_tls_handshake (struct MHD_Connection *connection)
static int
MHD_tls_connection_handle_read (struct MHD_Connection *connection)
{
- if (MHD_YES == run_tls_handshake (connection))
- return MHD_YES;
+ if (MHD_TLS_CONN_CONNECTED > connection->tls_state)
+ {
+ if (!run_tls_handshake(connection))
+ return MHD_YES;
+ }
return MHD_connection_handle_read (connection);
}
@@ -215,8 +219,11 @@ MHD_tls_connection_handle_read (struct MHD_Connection
*connection)
static int
MHD_tls_connection_handle_write (struct MHD_Connection *connection)
{
- if (MHD_YES == run_tls_handshake (connection))
- return MHD_YES;
+ if (MHD_TLS_CONN_CONNECTED > connection->tls_state)
+ {
+ if (!run_tls_handshake(connection))
+ return MHD_YES;
+ }
return MHD_connection_handle_write (connection);
}
--
To stop receiving notification emails like this one, please contact
address@hidden