Skip to content

Commit

Permalink
Merge remote-tracking branch 'tor-gitlab/merge-requests/43' into main…
Browse files Browse the repository at this point in the history
…t-0.4.4
  • Loading branch information
ahf committed Jul 14, 2020
2 parents 515d4f1 + 40eb6b1 commit 07f3345
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
5 changes: 5 additions & 0 deletions changes/ticket40035
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
o Major bugfixes (NSS):
- When running with NSS enabled, make sure that NSS knows to expect
nonblocking sockets. Previously, we set our TCP sockets as blocking,
but did not tell NSS about the fact, which in turn could lead to
unexpected blocking behavior. Fixes bug 40035; bugfix on 0.3.5.1-alpha.
10 changes: 10 additions & 0 deletions src/lib/tls/tortls_nss.c
Original file line number Diff line number Diff line change
Expand Up @@ -431,6 +431,16 @@ tor_tls_new(tor_socket_t sock, int is_server)
return NULL;
}

/* even if though the socket is already nonblocking, we need to tell NSS
* about the fact, so that it knows what to do when it says EAGAIN. */
PRSocketOptionData data;
data.option = PR_SockOpt_Nonblocking;
data.value.non_blocking = 1;
if (PR_SetSocketOption(ssl, &data) != PR_SUCCESS) {
PR_Close(ssl);
return NULL;
}

tor_tls_t *tls = tor_malloc_zero(sizeof(tor_tls_t));
tls->magic = TOR_TLS_MAGIC;
tls->context = ctx;
Expand Down

0 comments on commit 07f3345

Please sign in to comment.