summaryrefslogtreecommitdiff
path: root/src/core
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2018-09-14 10:22:38 -0400
committerNick Mathewson <nickm@torproject.org>2018-09-14 10:22:38 -0400
commite43ae24e7d8cc96eaed41b8e135232248ac39721 (patch)
tree779b708fc7ab44fbe116b2822af54c46258586fb /src/core
parentdbb0abc9f1a174efdb65d581f5dbe46dbad2ebb5 (diff)
parent9f5f67bda26979bb75e10a0ce0080997b1b72603 (diff)
downloadtor-e43ae24e7d8cc96eaed41b8e135232248ac39721.tar.gz
tor-e43ae24e7d8cc96eaed41b8e135232248ac39721.zip
Merge branch 'nss_27451'
Diffstat (limited to 'src/core')
-rw-r--r--src/core/mainloop/connection.c15
1 files changed, 13 insertions, 2 deletions
diff --git a/src/core/mainloop/connection.c b/src/core/mainloop/connection.c
index 7ef7423b13..0c3abc8442 100644
--- a/src/core/mainloop/connection.c
+++ b/src/core/mainloop/connection.c
@@ -638,8 +638,19 @@ connection_free_minimal(connection_t *conn)
if (connection_speaks_cells(conn)) {
or_connection_t *or_conn = TO_OR_CONN(conn);
- tor_tls_free(or_conn->tls);
- or_conn->tls = NULL;
+ if (or_conn->tls) {
+ if (! SOCKET_OK(conn->s)) {
+ /* The socket has been closed by somebody else; we must tell the
+ * TLS object not to close it. */
+ tor_tls_release_socket(or_conn->tls);
+ } else {
+ /* The tor_tls_free() call below will close the socket; we must tell
+ * the code below not to close it a second time. */
+ conn->s = TOR_INVALID_SOCKET;
+ }
+ tor_tls_free(or_conn->tls);
+ or_conn->tls = NULL;
+ }
or_handshake_state_free(or_conn->handshake_state);
or_conn->handshake_state = NULL;
tor_free(or_conn->nickname);