From 503a02867d4ae1a65af11fd6e4dd91cc499838d1 Mon Sep 17 00:00:00 2001 From: Hiroshi Saito Date: Mon, 28 Jan 2008 16:10:10 +0000 Subject: [PATCH] Fix bug of the selection not using SSL. Per report Stephen M. Lathrop. --- connection.c | 4 ++++ socket.c | 14 ++++++++++---- socket.h | 2 +- version.h | 2 +- 4 files changed, 16 insertions(+), 6 deletions(-) diff --git a/connection.c b/connection.c index 1019e66..bed850b 100644 --- a/connection.c +++ b/connection.c @@ -3678,8 +3678,10 @@ cleanup1: socket = PQsocket(pqconn); inolog("socket=%d\n", socket); sock->socket = socket; +#ifdef USE_SSL sock->ssl = PQgetssl(pqconn); inolog("ssl=%p\n", sock->ssl); +#endif if (TRUE) { int pversion; @@ -3717,11 +3719,13 @@ if (TRUE) /* ioctlsocket(sock, FIONBIO , 0); setsockopt(sock, IPPROTO_TCP, TCP_NODELAY, (char *) &on, sizeof(on)); */ } +#ifdef USE_SSL if (sock->ssl) { /* flags = fcntl(sock, F_GETFL); fcntl(sock, F_SETFL, flags & (~O_NONBLOCKING));*/ } +#endif mylog("Server version=%s\n", self->pg_version); ret = 1; if (ret) diff --git a/socket.c b/socket.c index 8e00222..bd0fcb71 100644 --- a/socket.c +++ b/socket.c @@ -17,7 +17,9 @@ #endif /* USE_SSPI */ #ifndef NOT_USE_LIBPQ #include +#ifdef USE_SSL #include +#endif /* USE_SSL */ #endif /* NOT_USE_LIBPQ */ #include "socket.h" #include "loadlib.h" @@ -82,7 +84,9 @@ SOCK_Constructor(const ConnectionClass *conn) #endif /* USE_SSPI */ #ifndef NOT_USE_LIBPQ rv->via_libpq = FALSE; +#ifdef USE_SSL rv->ssl = NULL; +#endif rv->pqconn = NULL; #endif /* NOT_USE_LIBPQ */ rv->pversion = 0; @@ -134,7 +138,9 @@ SOCK_Destructor(SocketClass *self) } self->via_libpq = FALSE; self->pqconn = NULL; +#ifdef USE_SSL self->ssl = NULL; +#endif } else #endif /* NOT_USE_LIBPQ */ @@ -458,10 +464,10 @@ static int SOCK_wait_for_ready(SocketClass *sock, BOOL output, int retry_count) no_timeout = FALSE; else if (0 > retry_count) no_timeout = TRUE; -#ifndef NOT_USE_LIBPQ +#ifdef USE_SSL else if (sock && NULL == sock->ssl) no_timeout = TRUE; -#endif /* NOT_USE_LIBPQ */ +#endif /* USE_SSL */ do { FD_ZERO(&fds); FD_ZERO(&except_fds); @@ -514,7 +520,7 @@ static int SOCK_SSPI_send(SocketClass *self, const void *buffer, int len) /* * The stuff for SSL. */ -/* included in +/* included in */ #define SSL_ERROR_NONE 0 #define SSL_ERROR_SSL 1 #define SSL_ERROR_WANT_READ 2 @@ -524,7 +530,7 @@ static int SOCK_SSPI_send(SocketClass *self, const void *buffer, int len) #define SSL_ERROR_ZERO_RETURN 6 #define SSL_ERROR_WANT_CONNECT 7 #define SSL_ERROR_WANT_ACCEPT 8 -*/ + /* * recv more than 1 bytes using SSL. diff --git a/socket.h b/socket.h index 927bcc7..3ca7071 100644 --- a/socket.h +++ b/socket.h @@ -141,9 +141,9 @@ struct SocketClass_ #ifdef USE_SSL /* SSL stuff */ void *ssl; /* libpq ssl */ +#endif /* USE_SSL */ void *pqconn; /* libpq PGConn */ BOOL via_libpq; /* using libpq library ? */ -#endif /* USE_SSL */ char reverse; /* used to handle Postgres 6.2 protocol * (reverse byte order) */ diff --git a/version.h b/version.h index 2058893..cfa66ec 100644 --- a/version.h +++ b/version.h @@ -12,6 +12,6 @@ #define POSTGRESDRIVERVERSION "08.03.0100" #define POSTGRES_RESOURCE_VERSION "08.03.0100\0" #define PG_DRVFILE_VERSION 8,3,01,00 -#define PG_BUILD_VERSION "200801220001" +#define PG_BUILD_VERSION "200801290001" #endif -- 2.39.5