summaryrefslogtreecommitdiff
path: root/src/src/ip.c
diff options
context:
space:
mode:
authorJeremy Harris <jgh146exb@wizmail.org>2018-06-21 19:16:29 +0100
committerJeremy Harris <jgh146exb@wizmail.org>2018-06-24 18:00:40 +0100
commit74f1a42304ce056cf979d22fb970faae161e3ab2 (patch)
treee8d3297cb6b9a05967e4c41527f71e934ec254c6 /src/src/ip.c
parentb24eb9cd4cd3bacbb044090cba7140a012b3eabb (diff)
TLS: rework client-side use with an explicit context rather than a global
Diffstat (limited to 'src/src/ip.c')
-rw-r--r--src/src/ip.c16
1 files changed, 8 insertions, 8 deletions
diff --git a/src/src/ip.c b/src/src/ip.c
index 2e8968528..555dc2d84 100644
--- a/src/src/ip.c
+++ b/src/src/ip.c
@@ -591,7 +591,7 @@ getting interrupted, and the possibility of select() returning with a positive
result but no ready descriptor. Is this in fact possible?
Arguments:
- sock the socket
+ cctx the connection context (socket fd, possibly TLS context)
buffer to read into
bufsize the buffer size
timeout the timeout
@@ -601,24 +601,24 @@ Returns: > 0 => that much data read
*/
int
-ip_recv(int sock, uschar *buffer, int buffsize, int timeout)
+ip_recv(client_conn_ctx * cctx, uschar * buffer, int buffsize, int timeout)
{
int rc;
-if (!fd_ready(sock, timeout))
+if (!fd_ready(cctx->sock, timeout))
return -1;
/* The socket is ready, read from it (via TLS if it's active). On EOF (i.e.
close down of the connection), set errno to zero; otherwise leave it alone. */
#ifdef SUPPORT_TLS
-if (tls_out.active == sock)
- rc = tls_read(FALSE, buffer, buffsize);
-else if (tls_in.active == sock)
- rc = tls_read(TRUE, buffer, buffsize);
+if (cctx->tls_ctx) /* client TLS */
+ rc = tls_read(cctx->tls_ctx, buffer, buffsize);
+else if (tls_in.active.sock == cctx->sock) /* server TLS */
+ rc = tls_read(NULL, buffer, buffsize);
else
#endif
- rc = recv(sock, buffer, buffsize, 0);
+ rc = recv(cctx->sock, buffer, buffsize, 0);
if (rc > 0) return rc;
if (rc == 0) errno = 0;