From: Tom Lane Date: Mon, 4 Aug 2003 17:58:25 +0000 (+0000) Subject: SSL_read/SSL_write do not approximate the return conventions of recv() X-Git-Url: http://git.postgresql.org/gitweb/static/gitweb.js?a=commitdiff_plain;h=1ee983b7bb35e77c59962f69d5364c53482bb333;p=users%2Fbernd%2Fpostgres.git SSL_read/SSL_write do not approximate the return conventions of recv() and send() very well at all; and in any case we can't use retval==0 for EOF due to race conditions. Make the same fixes in the backend as are required in libpq. --- diff --git a/src/backend/libpq/be-secure.c b/src/backend/libpq/be-secure.c index 9a635aaa72..a7fa1a6ca6 100644 --- a/src/backend/libpq/be-secure.c +++ b/src/backend/libpq/be-secure.c @@ -287,18 +287,22 @@ secure_read(Port *port, void *ptr, size_t len) if (n == -1) elog(COMMERROR, "SSL SYSCALL error: %m"); else + { elog(COMMERROR, "SSL SYSCALL error: EOF detected"); + errno = ECONNRESET; + n = -1; + } break; case SSL_ERROR_SSL: elog(COMMERROR, "SSL error: %s", SSLerrmessage()); /* fall through */ case SSL_ERROR_ZERO_RETURN: - secure_close(port); errno = ECONNRESET; n = -1; break; default: elog(COMMERROR, "Unknown SSL error code"); + n = -1; break; } } @@ -352,18 +356,22 @@ secure_write(Port *port, void *ptr, size_t len) if (n == -1) elog(COMMERROR, "SSL SYSCALL error: %m"); else + { elog(COMMERROR, "SSL SYSCALL error: EOF detected"); + errno = ECONNRESET; + n = -1; + } break; case SSL_ERROR_SSL: elog(COMMERROR, "SSL error: %s", SSLerrmessage()); /* fall through */ case SSL_ERROR_ZERO_RETURN: - secure_close(port); errno = ECONNRESET; n = -1; break; default: elog(COMMERROR, "Unknown SSL error code"); + n = -1; break; } }