From 6bdb7aa4db5571c83c87f5f761d4af4bc73e166e Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Sun, 8 Jun 2003 17:43:00 +0000 Subject: libpq can now talk to either 3.0 or 2.0 protocol servers. It first tries protocol 3, then falls back to 2 if postmaster rejects the startup packet with an old-format error message. A side benefit of the rewrite is that SSL-encrypted connections can now be made without blocking. (I think, anyway, but do not have a good way to test.) --- src/backend/libpq/ip.c | 32 +++++++++++++++++--------------- 1 file changed, 17 insertions(+), 15 deletions(-) (limited to 'src/backend/libpq/ip.c') diff --git a/src/backend/libpq/ip.c b/src/backend/libpq/ip.c index abb0f725927..83a5145c363 100644 --- a/src/backend/libpq/ip.c +++ b/src/backend/libpq/ip.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/libpq/ip.c,v 1.7 2003/04/22 03:52:56 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/libpq/ip.c,v 1.8 2003/06/08 17:42:59 tgl Exp $ * * This file and the IPV6 implementation were initially provided by * Nigel Kukard , Linux Based Systems Design @@ -72,27 +72,29 @@ getaddrinfo2(const char *hostname, const char *servname, /* - * freeaddrinfo2 - free IPv6 addrinfo structures + * freeaddrinfo2 - free addrinfo structures for IPv4, IPv6, or Unix */ void -freeaddrinfo2(int hint_ai_family, struct addrinfo *ai) +freeaddrinfo2(struct addrinfo *ai) { -#ifdef HAVE_UNIX_SOCKETS - if (hint_ai_family == AF_UNIX) + if (ai != NULL) { - struct addrinfo *p; - - while (ai != NULL) +#ifdef HAVE_UNIX_SOCKETS + if (ai->ai_family == AF_UNIX) { - p = ai; - ai = ai->ai_next; - free(p->ai_addr); - free(p); + while (ai != NULL) + { + struct addrinfo *p = ai; + + ai = ai->ai_next; + free(p->ai_addr); + free(p); + } } - } - else + else #endif /* HAVE_UNIX_SOCKETS */ - freeaddrinfo(ai); + freeaddrinfo(ai); + } } -- cgit v1.2.3