Commit 8fc86dd5 authored by Bruce Momjian's avatar Bruce Momjian

We have just finished porting the old KAME IPv6 patch over to

postgresql version 7.3, but yea... this patch adds full IPv6
support to postgres. I've tested it out on 7.2.3 and has
been running perfectly stable.

CREDITS:
 The KAME Project  (Initial patch)
 Nigel Kukard  <nkukard@lbsd.net>
 Johan Jordaan  <johanj@lando.co.za>
parent 87cba401
...@@ -15778,7 +15778,7 @@ fi ...@@ -15778,7 +15778,7 @@ fi
ac_config_files="$ac_config_files GNUmakefile src/Makefile.global" ac_config_files="$ac_config_files GNUmakefile src/Makefile.global"
ac_config_links="$ac_config_links src/backend/port/dynloader.c:src/backend/port/dynloader/${template}.c src/backend/port/pg_sema.c:${SEMA_IMPLEMENTATION} src/backend/port/pg_shmem.c:${SHMEM_IMPLEMENTATION} src/include/dynloader.h:src/backend/port/dynloader/${template}.h src/include/pg_config_os.h:src/include/port/${template}.h src/Makefile.port:src/makefiles/Makefile.${template}" ac_config_links="$ac_config_links src/backend/port/dynloader.c:src/backend/port/dynloader/${template}.c src/backend/port/pg_sema.c:${SEMA_IMPLEMENTATION} src/backend/port/pg_shmem.c:${SHMEM_IMPLEMENTATION} src/include/dynloader.h:src/backend/port/dynloader/${template}.h src/include/pg_config_os.h:src/include/port/${template}.h src/Makefile.port:src/makefiles/Makefile.${template} src/interfaces/libpq/v6util.c:src/backend/libpq/v6util.c"
ac_config_headers="$ac_config_headers src/include/pg_config.h" ac_config_headers="$ac_config_headers src/include/pg_config.h"
...@@ -16266,6 +16266,7 @@ do ...@@ -16266,6 +16266,7 @@ do
"src/include/dynloader.h" ) CONFIG_LINKS="$CONFIG_LINKS src/include/dynloader.h:src/backend/port/dynloader/${template}.h" ;; "src/include/dynloader.h" ) CONFIG_LINKS="$CONFIG_LINKS src/include/dynloader.h:src/backend/port/dynloader/${template}.h" ;;
"src/include/pg_config_os.h" ) CONFIG_LINKS="$CONFIG_LINKS src/include/pg_config_os.h:src/include/port/${template}.h" ;; "src/include/pg_config_os.h" ) CONFIG_LINKS="$CONFIG_LINKS src/include/pg_config_os.h:src/include/port/${template}.h" ;;
"src/Makefile.port" ) CONFIG_LINKS="$CONFIG_LINKS src/Makefile.port:src/makefiles/Makefile.${template}" ;; "src/Makefile.port" ) CONFIG_LINKS="$CONFIG_LINKS src/Makefile.port:src/makefiles/Makefile.${template}" ;;
"src/interfaces/libpq/v6util.c" ) CONFIG_LINKS="$CONFIG_LINKS src/interfaces/libpq/v6util.c:src/backend/libpq/v6util.c" ;;
"src/include/pg_config.h" ) CONFIG_HEADERS="$CONFIG_HEADERS src/include/pg_config.h" ;; "src/include/pg_config.h" ) CONFIG_HEADERS="$CONFIG_HEADERS src/include/pg_config.h" ;;
*) { { echo "$as_me:$LINENO: error: invalid argument: $ac_config_target" >&5 *) { { echo "$as_me:$LINENO: error: invalid argument: $ac_config_target" >&5
echo "$as_me: error: invalid argument: $ac_config_target" >&2;} echo "$as_me: error: invalid argument: $ac_config_target" >&2;}
......
dnl Process this file with autoconf to produce a configure script. dnl Process this file with autoconf to produce a configure script.
dnl $Header: /cvsroot/pgsql/configure.in,v 1.219 2002/12/03 21:50:43 momjian Exp $ dnl $Header: /cvsroot/pgsql/configure.in,v 1.220 2002/12/06 03:46:24 momjian Exp $
dnl dnl
dnl Developers, please strive to achieve this order: dnl Developers, please strive to achieve this order:
dnl dnl
...@@ -1182,6 +1182,7 @@ AC_CONFIG_LINKS([ ...@@ -1182,6 +1182,7 @@ AC_CONFIG_LINKS([
src/include/dynloader.h:src/backend/port/dynloader/${template}.h src/include/dynloader.h:src/backend/port/dynloader/${template}.h
src/include/pg_config_os.h:src/include/port/${template}.h src/include/pg_config_os.h:src/include/port/${template}.h
src/Makefile.port:src/makefiles/Makefile.${template} src/Makefile.port:src/makefiles/Makefile.${template}
src/interfaces/libpq/v6util.c:src/backend/libpq/v6util.c
]) ])
AC_CONFIG_HEADERS([src/include/pg_config.h], AC_CONFIG_HEADERS([src/include/pg_config.h],
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
# Makefile for libpq subsystem (backend half of libpq interface) # Makefile for libpq subsystem (backend half of libpq interface)
# #
# IDENTIFICATION # IDENTIFICATION
# $Header: /cvsroot/pgsql/src/backend/libpq/Makefile,v 1.33 2002/06/14 04:23:17 momjian Exp $ # $Header: /cvsroot/pgsql/src/backend/libpq/Makefile,v 1.34 2002/12/06 03:46:24 momjian Exp $
# #
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
...@@ -15,7 +15,7 @@ include $(top_builddir)/src/Makefile.global ...@@ -15,7 +15,7 @@ include $(top_builddir)/src/Makefile.global
# be-fsstubs is here for historical reasons, probably belongs elsewhere # be-fsstubs is here for historical reasons, probably belongs elsewhere
OBJS = be-fsstubs.o be-secure.o auth.o crypt.o hba.o md5.o pqcomm.o \ OBJS = be-fsstubs.o be-secure.o auth.o crypt.o hba.o md5.o pqcomm.o \
pqformat.o pqsignal.o pqformat.o pqsignal.o v6util.o
all: SUBSYS.o all: SUBSYS.o
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/libpq/auth.c,v 1.92 2002/12/03 22:09:19 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/libpq/auth.c,v 1.93 2002/12/06 03:46:24 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -410,9 +410,12 @@ ClientAuthentication(Port *port) ...@@ -410,9 +410,12 @@ ClientAuthentication(Port *port)
*/ */
{ {
const char *hostinfo = "localhost"; const char *hostinfo = "localhost";
char ip_hostinfo[INET6_ADDRSTRLEN];
if (isAF_INETx(&port->raddr.sa) ){
hostinfo = SockAddr_ntop(&port->raddr, ip_hostinfo,
INET6_ADDRSTRLEN, 1);
}
if (port->raddr.sa.sa_family == AF_INET)
hostinfo = inet_ntoa(port->raddr.in.sin_addr);
elog(FATAL, elog(FATAL,
"No pg_hba.conf entry for host %s, user %s, database %s", "No pg_hba.conf entry for host %s, user %s, database %s",
hostinfo, port->user, port->database); hostinfo, port->user, port->database);
......
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/libpq/hba.c,v 1.88 2002/12/03 21:50:44 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/libpq/hba.c,v 1.89 2002/12/06 03:46:26 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -582,9 +582,8 @@ parse_hba(List *line, hbaPort *port, bool *found_p, bool *error_p) ...@@ -582,9 +582,8 @@ parse_hba(List *line, hbaPort *port, bool *found_p, bool *error_p)
} }
else if (strcmp(token, "host") == 0 || strcmp(token, "hostssl") == 0) else if (strcmp(token, "host") == 0 || strcmp(token, "hostssl") == 0)
{ {
struct in_addr file_ip_addr, SockAddr file_ip_addr, mask;
mask;
if (strcmp(token, "hostssl") == 0) if (strcmp(token, "hostssl") == 0)
{ {
#ifdef USE_SSL #ifdef USE_SSL
...@@ -619,16 +618,25 @@ parse_hba(List *line, hbaPort *port, bool *found_p, bool *error_p) ...@@ -619,16 +618,25 @@ parse_hba(List *line, hbaPort *port, bool *found_p, bool *error_p)
if (!line) if (!line)
goto hba_syntax; goto hba_syntax;
token = lfirst(line); token = lfirst(line);
if (!inet_aton(token, &file_ip_addr))
goto hba_syntax; if(SockAddr_pton(&file_ip_addr, token, strlen(token)) < 0){
goto hba_syntax;
}
/* Read the mask field. */ /* Read the mask field. */
line = lnext(line); line = lnext(line);
if (!line) if (!line)
goto hba_syntax; goto hba_syntax;
token = lfirst(line); token = lfirst(line);
if (!inet_aton(token, &mask))
goto hba_syntax; if(SockAddr_pton(&mask, token, strlen(token)) < 0){
goto hba_syntax;
}
if(file_ip_addr.sa.sa_family != mask.sa.sa_family){
goto hba_syntax;
}
/* Read the rest of the line. */ /* Read the rest of the line. */
line = lnext(line); line = lnext(line);
...@@ -639,8 +647,7 @@ parse_hba(List *line, hbaPort *port, bool *found_p, bool *error_p) ...@@ -639,8 +647,7 @@ parse_hba(List *line, hbaPort *port, bool *found_p, bool *error_p)
goto hba_syntax; goto hba_syntax;
/* Must meet network restrictions */ /* Must meet network restrictions */
if (port->raddr.sa.sa_family != AF_INET || if (!isAF_INETx(&port->raddr) || !rangeSockAddr(&port->raddr, &file_ip_addr, &mask))
((file_ip_addr.s_addr ^ port->raddr.in.sin_addr.s_addr) & mask.s_addr) != 0)
return; return;
} }
else else
......
...@@ -44,5 +44,6 @@ ...@@ -44,5 +44,6 @@
# TYPE DATABASE USER IP-ADDRESS IP-MASK METHOD # TYPE DATABASE USER IP-ADDRESS IP-MASK METHOD
local all all trust local all all trust
host all all 127.0.0.1 255.255.255.255 trust host all all 127.0.0.1 255.255.255.255 trust
host all all ::1 ffff:ffff:ffff:fff:ffff:ffff:ffff trust
This diff is collapsed.
...@@ -37,7 +37,7 @@ ...@@ -37,7 +37,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/postmaster/postmaster.c,v 1.299 2002/11/21 06:36:08 tgl Exp $ * $Header: /cvsroot/pgsql/src/backend/postmaster/postmaster.c,v 1.300 2002/12/06 03:46:29 momjian Exp $
* *
* NOTES * NOTES
* *
...@@ -669,7 +669,7 @@ PostmasterMain(int argc, char *argv[]) ...@@ -669,7 +669,7 @@ PostmasterMain(int argc, char *argv[])
*/ */
if (NetServer) if (NetServer)
{ {
status = StreamServerPort(AF_INET, VirtualHost, status = StreamServerPort(AF_INET6, VirtualHost,
(unsigned short) PostPortNumber, (unsigned short) PostPortNumber,
UnixSocketDir, UnixSocketDir,
&ServerSock_INET); &ServerSock_INET);
...@@ -2091,13 +2091,14 @@ DoBackend(Port *port) ...@@ -2091,13 +2091,14 @@ DoBackend(Port *port)
/* /*
* Get the remote host name and port for logging and status display. * Get the remote host name and port for logging and status display.
*/ */
if (port->raddr.sa.sa_family == AF_INET) if (isAF_INETx(&port->raddr))
{ {
unsigned short remote_port; unsigned short remote_port;
char *host_addr; char *host_addr;
char ip_hostinfo[INET6_ADDRSTRLEN];
remote_port = ntohs(port->raddr.in.sin_port); remote_port = ntohs(port->raddr.in.sin_port);
host_addr = inet_ntoa(port->raddr.in.sin_addr); host_addr = SockAddr_ntop(&port->raddr, ip_hostinfo, INET6_ADDRSTRLEN, 1);
remote_host = NULL; remote_host = NULL;
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group * Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California * Portions Copyright (c) 1994, Regents of the University of California
* *
* $Id: libpq.h,v 1.52 2002/09/04 23:31:35 tgl Exp $ * $Id: libpq.h,v 1.53 2002/12/06 03:46:32 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -19,6 +19,7 @@ ...@@ -19,6 +19,7 @@
#include "lib/stringinfo.h" #include "lib/stringinfo.h"
#include "libpq/libpq-be.h" #include "libpq/libpq-be.h"
#include "libpq/v6util.h"
/* ---------------- /* ----------------
* PQArgBlock * PQArgBlock
......
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group * Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California * Portions Copyright (c) 1994, Regents of the University of California
* *
* $Id: pqcomm.h,v 1.70 2002/09/04 20:31:42 momjian Exp $ * $Id: pqcomm.h,v 1.71 2002/12/06 03:46:33 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -47,6 +47,7 @@ typedef union SockAddr ...@@ -47,6 +47,7 @@ typedef union SockAddr
{ {
struct sockaddr sa; struct sockaddr sa;
struct sockaddr_in in; struct sockaddr_in in;
struct sockaddr_in6 in6;
struct sockaddr_un un; struct sockaddr_un un;
} SockAddr; } SockAddr;
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
# #
# Copyright (c) 1994, Regents of the University of California # Copyright (c) 1994, Regents of the University of California
# #
# $Header: /cvsroot/pgsql/src/interfaces/libpq/Makefile,v 1.66 2002/12/04 18:14:11 momjian Exp $ # $Header: /cvsroot/pgsql/src/interfaces/libpq/Makefile,v 1.67 2002/12/06 03:46:37 momjian Exp $
# #
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
...@@ -23,6 +23,7 @@ override CPPFLAGS := -I$(srcdir) $(CPPFLAGS) -DFRONTEND -DSYSCONFDIR='"$(sysconf ...@@ -23,6 +23,7 @@ override CPPFLAGS := -I$(srcdir) $(CPPFLAGS) -DFRONTEND -DSYSCONFDIR='"$(sysconf
OBJS= fe-auth.o fe-connect.o fe-exec.o fe-misc.o fe-print.o fe-lobj.o \ OBJS= fe-auth.o fe-connect.o fe-exec.o fe-misc.o fe-print.o fe-lobj.o \
pqexpbuffer.o dllist.o md5.o pqsignal.o fe-secure.o \ pqexpbuffer.o dllist.o md5.o pqsignal.o fe-secure.o \
wchar.o encnames.o \ wchar.o encnames.o \
v6util.o \
$(filter inet_aton.o snprintf.o strerror.o, $(LIBOBJS)) $(filter inet_aton.o snprintf.o strerror.o, $(LIBOBJS))
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-connect.c,v 1.213 2002/10/24 23:35:55 tgl Exp $ * $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-connect.c,v 1.214 2002/12/06 03:46:37 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -39,6 +39,9 @@ ...@@ -39,6 +39,9 @@
#include <arpa/inet.h> #include <arpa/inet.h>
#endif #endif
#include "libpq/v6util.h"
#ifndef HAVE_STRDUP #ifndef HAVE_STRDUP
#include "strdup.h" #include "strdup.h"
#endif #endif
...@@ -786,6 +789,15 @@ connectDBStart(PGconn *conn) ...@@ -786,6 +789,15 @@ connectDBStart(PGconn *conn)
{ {
int portno, int portno,
family; family;
struct addrinfo* addrs = NULL;
struct addrinfo* addr_cur = NULL;
struct addrinfo hint;
const char* node = NULL;
const char* unix_node = "unix";
char portNoStr[64];
int ret;
int sockfd;
#ifdef USE_SSL #ifdef USE_SSL
StartupPacket np; /* Used to negotiate SSL connection */ StartupPacket np; /* Used to negotiate SSL connection */
...@@ -815,101 +827,67 @@ connectDBStart(PGconn *conn) ...@@ -815,101 +827,67 @@ connectDBStart(PGconn *conn)
MemSet((char *) &conn->raddr, 0, sizeof(conn->raddr)); MemSet((char *) &conn->raddr, 0, sizeof(conn->raddr));
if (conn->pghostaddr != NULL && conn->pghostaddr[0] != '\0') MemSet(&hint, 0, sizeof(hint));
{ hint.ai_socktype = SOCK_STREAM;
/* Using pghostaddr avoids a hostname lookup */ if(conn->pghostaddr != NULL && conn->pghostaddr[0] != '\0'){
/* Note that this supports IPv4 only */ node = conn->pghostaddr;
struct in_addr addr; hint.ai_family = AF_UNSPEC;
if (!inet_aton(conn->pghostaddr, &addr))
{
printfPQExpBuffer(&conn->errorMessage,
libpq_gettext("invalid host address: %s\n"),
conn->pghostaddr);
goto connect_errReturn;
}
family = AF_INET;
memmove((char *) &(conn->raddr.in.sin_addr),
(char *) &addr, sizeof(addr));
} }
else if (conn->pghost != NULL && conn->pghost[0] != '\0') else if (conn->pghost != NULL && conn->pghost[0] != '\0'){
{ node = conn->pghost;
/* Using pghost, so we have to look-up the hostname */ hint.ai_family = AF_UNSPEC;
struct hostent *hp;
hp = gethostbyname(conn->pghost);
if ((hp == NULL) || (hp->h_addrtype != AF_INET))
{
printfPQExpBuffer(&conn->errorMessage,
libpq_gettext("unknown host name: %s\n"),
conn->pghost);
goto connect_errReturn;
}
family = AF_INET;
memmove((char *) &(conn->raddr.in.sin_addr),
(char *) hp->h_addr,
hp->h_length);
} }
else #ifdef HAVE_UNIX_SOCKETS
{ else {
/* pghostaddr and pghost are NULL, so use Unix domain socket */ node = unix_node;
family = AF_UNIX; hint.ai_family = AF_UNIX;
} }
#endif /* HAVE_UNIX_SOCKETS */
/* Set family */
conn->raddr.sa.sa_family = family;
/* Set port number */
if (conn->pgport != NULL && conn->pgport[0] != '\0') if (conn->pgport != NULL && conn->pgport[0] != '\0')
portno = atoi(conn->pgport); portno = atoi(conn->pgport);
else else
portno = DEF_PGPORT; portno = DEF_PGPORT;
if (family == AF_INET) if(hint.ai_family == AF_UNSPEC){
{ snprintf(portNoStr, sizeof(portNoStr)/sizeof(char),
conn->raddr.in.sin_port = htons((unsigned short) (portno)); "%d", portno);
conn->raddr_len = sizeof(struct sockaddr_in);
} }
#ifdef HAVE_UNIX_SOCKETS #ifdef HAVE_UNIX_SOCKETS
else else {
{ UNIXSOCK_PATH(conn->raddr.un, portno, conn->pgunixsocket);
UNIXSOCK_PATH(conn->raddr.un, portno, conn->pgunixsocket); conn->raddr_len = UNIXSOCK_LEN(conn->raddr.un);
conn->raddr_len = UNIXSOCK_LEN(conn->raddr.un); strcpy(portNoStr, conn->raddr.un.sun_path);
#ifdef USE_SSL #ifdef USE_SSL
/* Don't bother requesting SSL over a Unix socket */ /* Don't bother requesting SSL over a Unix socket */
conn->allow_ssl_try = false; conn->allow_ssl_try = false;
conn->require_ssl = false; conn->require_ssl = false;
#endif #endif
} }
#endif #endif /* HAVE_UNIX_SOCKETS */
/* Open a socket */ ret = getaddrinfo2(node, portNoStr, &hint, &addrs);
if ((conn->sock = socket(family, SOCK_STREAM, 0)) < 0) if(ret || addrs == NULL){
{ printfPQExpBuffer(&conn->errorMessage,
printfPQExpBuffer(&conn->errorMessage, libpq_gettext("failed to getaddrinfo(): %s\n"),
libpq_gettext("could not create socket: %s\n"), gai_strerror(ret) );
SOCK_STRERROR(SOCK_ERRNO)); goto connect_errReturn;
goto connect_errReturn;
}
/*
* Set the right options. Normally, we need nonblocking I/O, and we
* don't want delay of outgoing data for AF_INET sockets. If we are
* using SSL, then we need the blocking I/O (XXX Can this be fixed?).
*/
if (family == AF_INET)
{
if (!connectNoDelay(conn))
goto connect_errReturn;
} }
addr_cur = addrs;
do {
sockfd = socket(addr_cur->ai_family, addr_cur->ai_socktype,
addr_cur->ai_protocol);
if(sockfd < 0){
continue;
}
conn->sock = sockfd;
if (isAF_INETx2(addr_cur->ai_family) ){
if (!connectNoDelay(conn))
goto connect_errReturn;
}
#if !defined(USE_SSL) #if !defined(USE_SSL)
if (connectMakeNonblocking(conn) == 0) if (connectMakeNonblocking(conn) == 0)
goto connect_errReturn; goto connect_errReturn;
#endif #endif
/* ---------- /* ----------
...@@ -922,31 +900,42 @@ connectDBStart(PGconn *conn) ...@@ -922,31 +900,42 @@ connectDBStart(PGconn *conn)
* ---------- * ----------
*/ */
retry1: retry1:
if (connect(conn->sock, &conn->raddr.sa, conn->raddr_len) < 0) if(connect(sockfd, addr_cur->ai_addr, addr_cur->ai_addrlen) == 0){
{ /* We're connected already */
conn->status = CONNECTION_MADE;
break;
}
else {
if (SOCK_ERRNO == EINTR) if (SOCK_ERRNO == EINTR)
/* Interrupted system call - we'll just try again */ /* Interrupted system call - we'll just try again */
goto retry1; goto retry1;
if (SOCK_ERRNO == EINPROGRESS || SOCK_ERRNO == EWOULDBLOCK || SOCK_ERRNO == 0) if (SOCK_ERRNO == EINPROGRESS || SOCK_ERRNO == EWOULDBLOCK || SOCK_ERRNO == 0){
{
/* /*
* This is fine - we're in non-blocking mode, and the * This is fine - we're in non-blocking mode, and the
* connection is in progress. * connection is in progress.
*/ */
conn->status = CONNECTION_STARTED; conn->status = CONNECTION_STARTED;
} break;
else }
{ }
/* Something's gone wrong */ close(sockfd);
connectFailureMessage(conn, SOCK_ERRNO); } while( (addr_cur = addr_cur->ai_next) != NULL);
goto connect_errReturn;
} if(addr_cur == NULL){
printfPQExpBuffer(&conn->errorMessage,
libpq_gettext("could not create socket: %s\n"),
SOCK_STRERROR(SOCK_ERRNO));
goto connect_errReturn;
} }
else else {
{ family = addr_cur->ai_family;
/* We're connected already */ memmove(&conn->raddr, addr_cur->ai_addr, addr_cur->ai_addrlen);
conn->status = CONNECTION_MADE; conn->raddr_len = addr_cur->ai_addrlen;
freeaddrinfo2(hint.ai_family, addrs);
addrs = NULL;
} }
#ifdef USE_SSL #ifdef USE_SSL
...@@ -1038,7 +1027,9 @@ connect_errReturn: ...@@ -1038,7 +1027,9 @@ connect_errReturn:
conn->sock = -1; conn->sock = -1;
} }
conn->status = CONNECTION_BAD; conn->status = CONNECTION_BAD;
if(addrs != NULL){
freeaddrinfo2(hint.ai_family, addrs);
}
return 0; return 0;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment