diff options
author | Bruce Momjian <bruce@momjian.us> | 2002-06-15 20:01:31 +0000 |
---|---|---|
committer | Bruce Momjian <bruce@momjian.us> | 2002-06-15 20:01:31 +0000 |
commit | 79ff2e96dec1f6e87bd8e61754dfde9c6502f959 (patch) | |
tree | 4acc7d2a3dcae93854bcebdfbf7ab99540e1bf69 /src | |
parent | 6e8a1a6717956eb86113fb73f2bc3d0a22c542c6 (diff) | |
download | postgresql-79ff2e96dec1f6e87bd8e61754dfde9c6502f959.tar.gz postgresql-79ff2e96dec1f6e87bd8e61754dfde9c6502f959.zip |
PATCH SSL_pending() checks in libpq/fe-misc.c:
I am no longer pursuing a total non-blocking implementation. I haven't
found a good way to test it with the type of work that I do with
PostgreSQL. I do use blocking SSL sockets with this mod and have had no
problem whatsoever. The bug that I fixed in this patch is exceptionally
hard to reproduce reliably.
Jack Bates
Diffstat (limited to 'src')
-rw-r--r-- | src/interfaces/libpq/fe-misc.c | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/src/interfaces/libpq/fe-misc.c b/src/interfaces/libpq/fe-misc.c index 15b6dcb1e53..94b641621a3 100644 --- a/src/interfaces/libpq/fe-misc.c +++ b/src/interfaces/libpq/fe-misc.c @@ -25,7 +25,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-misc.c,v 1.73 2002/06/14 04:23:17 momjian Exp $ + * $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-misc.c,v 1.74 2002/06/15 20:01:31 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -351,6 +351,7 @@ pqPutInt(int value, size_t bytes, PGconn *conn) /* * pqReadReady: is select() saying the file is ready to read? + * JAB: -or- if SSL is enabled and used, is it buffering bytes? * Returns -1 on failure, 0 if not ready, 1 if ready. */ int @@ -362,6 +363,15 @@ pqReadReady(PGconn *conn) if (!conn || conn->sock < 0) return -1; +/* JAB: Check for SSL library buffering read bytes */ +#ifdef USE_SSL + if (conn->ssl && SSL_pending(conn->ssl) > 0) + { + /* short-circuit the select */ + return 1; + } +#endif + retry1: FD_ZERO(&input_mask); FD_SET(conn->sock, &input_mask); @@ -760,6 +770,9 @@ pqFlush(PGconn *conn) /* * pqWait: wait until we can read or write the connection socket * + * JAB: If SSL enabled and used and forRead, buffered bytes short-circuit the + * call to select(). + * * We also stop waiting and return if the kernel flags an exception condition * on the socket. The actual error condition will be detected and reported * when the caller tries to read or write the socket. @@ -778,6 +791,15 @@ pqWait(int forRead, int forWrite, PGconn *conn) return EOF; } +/* JAB: Check for SSL library buffering read bytes */ +#ifdef USE_SSL + if (forRead && conn->ssl && SSL_pending(conn->ssl) > 0) + { + /* short-circuit the select */ + return 0; + } +#endif + if (forRead || forWrite) { retry5: |