factor out socket_open_internal()
This commit is contained in:
parent
42cedc8f81
commit
f68e021b90
17
src/socket.c
17
src/socket.c
|
@ -285,6 +285,14 @@ static void socket_connect_failed( conn_t * );
|
||||||
static void socket_connected( conn_t * );
|
static void socket_connected( conn_t * );
|
||||||
static void socket_connect_bail( conn_t * );
|
static void socket_connect_bail( conn_t * );
|
||||||
|
|
||||||
|
static void
|
||||||
|
socket_open_internal( conn_t *sock, int fd )
|
||||||
|
{
|
||||||
|
sock->fd = fd;
|
||||||
|
fcntl( fd, F_SETFL, O_NONBLOCK );
|
||||||
|
add_fd( fd, socket_fd_cb, sock );
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
socket_close_internal( conn_t *sock )
|
socket_close_internal( conn_t *sock )
|
||||||
{
|
{
|
||||||
|
@ -322,10 +330,7 @@ socket_connect( conn_t *sock, void (*cb)( int ok, void *aux ) )
|
||||||
}
|
}
|
||||||
|
|
||||||
close( a[0] );
|
close( a[0] );
|
||||||
sock->fd = a[1];
|
socket_open_internal( sock, a[1] );
|
||||||
|
|
||||||
fcntl( a[1], F_SETFL, O_NONBLOCK );
|
|
||||||
add_fd( a[1], socket_fd_cb, sock );
|
|
||||||
|
|
||||||
info( "\vok\n" );
|
info( "\vok\n" );
|
||||||
socket_connected( sock );
|
socket_connected( sock );
|
||||||
|
@ -417,9 +422,7 @@ socket_connect_one( conn_t *sock )
|
||||||
perror( "socket" );
|
perror( "socket" );
|
||||||
exit( 1 );
|
exit( 1 );
|
||||||
}
|
}
|
||||||
sock->fd = s;
|
socket_open_internal( sock, s );
|
||||||
fcntl( s, F_SETFL, O_NONBLOCK );
|
|
||||||
add_fd( s, socket_fd_cb, sock );
|
|
||||||
|
|
||||||
infon( "Connecting to %s... ", sock->name );
|
infon( "Connecting to %s... ", sock->name );
|
||||||
#ifdef HAVE_IPV6
|
#ifdef HAVE_IPV6
|
||||||
|
|
Loading…
Reference in New Issue
Block a user