summaryrefslogtreecommitdiff
path: root/sockets.h
diff options
context:
space:
mode:
authorLuke Bratch <luke@bratch.co.uk>2019-07-09 22:36:35 +0100
committerLuke Bratch <luke@bratch.co.uk>2019-07-09 22:36:35 +0100
commit05d3d94613168187cbf7d54ac6de345bb75910dd (patch)
tree7293a4c9effa6a51683d091e3ff3debe1880f9db /sockets.h
parentc70cd5cccc966a35f175913f2281ce251fd62425 (diff)
Avoid SSL_accept() blocking if the client fails to do TLS negotiation.
Diffstat (limited to 'sockets.h')
-rw-r--r--sockets.h12
1 files changed, 12 insertions, 0 deletions
diff --git a/sockets.h b/sockets.h
index 4fb6c20..2a2ef1b 100644
--- a/sockets.h
+++ b/sockets.h
@@ -31,8 +31,10 @@
#include <sys/select.h>
#include <openssl/ssl.h>
#include <openssl/err.h>
+#include <fcntl.h>
#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