Skip to content

Commit 90b88fa

Browse files
committed
Don't set custom push/pull functions unconditionally
We set custom push/pull functions for GnuTLS so that it works under socket-wrapper. However, this has downsides: - There is a slight performance impact - We have also observed issues with nonblocking IO causing floods of EAGAIN errors in the test suite. This is fine for a test environment, but not when running for real. To avoid issues when the code is actually being used, only set the custom push/pull functions when SOCKET_WRAPPER_DIR environment variable is set, indicating that we're running under socket-wrapper. Signed-Off-By: Wouter Verhelst <w@uter.be>
1 parent b1cfcf0 commit 90b88fa

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

crypto-gnutls.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -386,8 +386,12 @@ tlssession_mainloop (int cryptfd, int plainfd, tlssession_t * s)
386386
/* set it up to work with our FD using custom push/pull functions */
387387
gnutls_transport_set_ptr (s->session,
388388
(gnutls_transport_ptr_t) (intptr_t) cryptfd);
389-
gnutls_transport_set_push_function (s->session, custom_gnutls_push);
390-
gnutls_transport_set_pull_function (s->session, custom_gnutls_pull);
389+
/* Only use custom push/pull functions when running under cwrap */
390+
char *socket_wrapper_dir = getenv("SOCKET_WRAPPER_DIR");
391+
if (socket_wrapper_dir && socket_wrapper_dir[0] != '\0') {
392+
gnutls_transport_set_push_function (s->session, custom_gnutls_push);
393+
gnutls_transport_set_pull_function (s->session, custom_gnutls_pull);
394+
}
391395

392396

393397
/* Now do the handshake */

0 commit comments

Comments
 (0)