From 5f5603ce239dce08ae2ec4b0fa828787b220493c Mon Sep 17 00:00:00 2001 From: eunhhu Date: Thu, 1 Oct 2026 09:10:55 +0100 Subject: Deliver wires on the sending loop, a step at a time (017, 2b-2) A wire is now a sender of link/sending.h: its request goes on a non-blocking socket as far as the socket takes it (connect, TLS handshake, write, answer read), and its round waits for the socket or its deadline (10 s with nothing moved). The answer is read as it comes: the head whole, then a sized body counted down, a chunked one (few and small) parsed again as it grows, or a body to the close. The crypto table (version 6) takes the TLS handshake a step at a time, and reads and writes say what they wait for. The owner pushes a wire once a turn, as it does a link. A host whose app sends to ten links and ten wires has 5 threads where it had 24 (none: 3). --- link/tls.h | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'link/tls.h') diff --git a/link/tls.h b/link/tls.h index 3939f21..232e192 100644 --- a/link/tls.h +++ b/link/tls.h @@ -8,10 +8,19 @@ typedef struct PureTls PureTls; /* The context, made once; false with why in error when it cannot be. */ bool pure_tls_start(const char *ca_file, char *error, size_t size); -/* A session over a connected socket to host (a DNS name, or an IP address - * written as one), its certificate verified; NULL when it fails. */ +/* A session over a connected, non-blocking socket to host (a DNS name, or + * an IP address written as one); NULL when it cannot be. Its handshake is + * made a step at a time, as the socket is ready, by pure_tls_step. */ PureTls *pure_tls_open(const char *host, int fd); -/* As SSL_read and SSL_write: the bytes moved, or <= 0. */ +/* What a step, a read or a write says when it moved no bytes: the session + * ended (the peer closed it), failed, or waits for the socket to be + * readable or writable (then the same again). */ +enum { PURE_TLS_CLOSED = 0, PURE_TLS_FAILED = -1, PURE_TLS_WANTS_READ = -2, PURE_TLS_WANTS_WRITE = -3 }; +/* The handshake: 1 once it is made and the receiver's certificate + * verified, else what it waits for, or PURE_TLS_FAILED. */ +int pure_tls_step(PureTls *); +/* As SSL_read and SSL_write: the bytes moved (a write may move part), or + * one of the above. */ int pure_tls_read(PureTls *, void *bytes, int size); int pure_tls_write(PureTls *, const void *bytes, int size); void pure_tls_close(PureTls *); -- cgit v1.2.3