de-duplicate cleanup of name-related data in error paths

"name" being both the ipv6 dns info and our own socket label.

sort-of amends 9d22641b.
This commit is contained in:
Oswald Buddenhagen 2015-09-06 21:02:23 +02:00
parent 167964933f
commit 9a0403f446

View File

@ -536,14 +536,22 @@ socket_connected( conn_t *conn )
}
static void
socket_connect_bail( conn_t *conn )
socket_cleanup_names( conn_t *conn )
{
#ifdef HAVE_IPV6
if (conn->addrs) {
freeaddrinfo( conn->addrs );
conn->addrs = 0;
}
#endif
free( conn->name );
conn->name = 0;
}
static void
socket_connect_bail( conn_t *conn )
{
socket_cleanup_names( conn );
conn->callbacks.connect( 0, conn->callback_aux );
}
@ -554,14 +562,7 @@ socket_close( conn_t *sock )
{
if (sock->fd >= 0)
socket_close_internal( sock );
free( sock->name );
sock->name = 0;
#ifdef HAVE_IPV6
if (sock->addrs) {
freeaddrinfo( sock->addrs );
sock->addrs = 0;
}
#endif
socket_cleanup_names( sock );
#ifdef HAVE_LIBSSL
if (sock->ssl) {
SSL_free( sock->ssl );