From 05d3d94613168187cbf7d54ac6de345bb75910dd Mon Sep 17 00:00:00 2001 From: Luke Bratch Date: Tue, 9 Jul 2019 22:36:35 +0100 Subject: Avoid SSL_accept() blocking if the client fails to do TLS negotiation. --- sockets.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'sockets.h') diff --git a/sockets.h b/sockets.h index 4fb6c20..2a2ef1b 100644 --- a/sockets.h +++ b/sockets.h @@ -31,8 +31,10 @@ #include #include #include +#include #include "functions.h" +#include "structures.h" #define DEBUG_CRIT 0 #define DEBUG_SOME 1 @@ -71,4 +73,14 @@ int socksend(SSL *fd, char *buf, int bufsize, int tls); // Return character array of latest OpenSSL error char *openssl_error_string(); +// Set a socket "fd" to be blocking ("blocking" = 1) or non-blocking ("blocking" = 0). +// Returns 1 on success or 0 on failure. +int fd_toggle_blocking(int fd, int blocking); + +// Attempt to do SSL_accept() on a client with fd "fd". Expects the socket fd to have just been set +// to non-blocking. Will make the socket blocking again and set the client's pendingsslaccept status +// to 0 if SSL_accept() succeeds. +// Returns 1 on success, 0 on hard failure, or -1 on SSL_ERROR_WANT_READ or SSL_ERROR_WANT_WRITE. +int openssl_accept(int fd, struct client *clients, struct ircdstate *ircdstate, struct settings *settings, struct clientcodes *clientcodes); + #endif -- cgit v1.2.3