From 64bdb8c3011be977c77ce7d1116204c7d578ca14 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Petr=20P=C3=ADsa=C5=99?= Date: Sat, 15 Dec 2012 21:17:31 +0100 Subject: [PATCH] test: server: push TLS manually This is needed to make GnuTLS to send(2) with MSG_NOSIGNAL. TODO: We must change HTTP socket to structure passing TLS session and TPC socket etc. --- test/simline/server.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/test/simline/server.c b/test/simline/server.c index 26bfd62..885dee5 100644 --- a/test/simline/server.c +++ b/test/simline/server.c @@ -623,6 +623,14 @@ static ssize_t send_tls(void *context, const void *buffer, size_t length, } +/* Call-back fot GnuTLS to send data to TCP socket. + * GnuTLS does not call send(2) with MSG_NOSIGNAL, we must do it manually */ +static ssize_t tls_push(gnutls_transport_ptr_t context, const void* buffer, + size_t length) { + return send((int)context, buffer, length, MSG_NOSIGNAL); +} + + /* Start sever in separate process. * @server_process is PID of forked server * @server_address is automatically allocated TCP address of listening server @@ -842,6 +850,7 @@ int start_server(pid_t *server_process, char **server_address, http_recv_callback = recv_tls; http_send_callback = send_tls; http_recv_context = http_send_context = tls_session; + gnutls_transport_set_push_function(tls_session, tls_push); } error = http_read_request(client_socket, &request); -- 2.11.4.GIT