commit a74309b3080d9bc957bf9061ea1c4af27c458262
Author: Oswald Buddenhagen <[email protected]>
Date: Fri Mar 29 17:51:50 2013 +0100
factor out socket_connect_failed()
src/socket.c | 22 +++++++++++++---------
1 files changed, 13 insertions(+), 9 deletions(-)
diff --git a/src/socket.c b/src/socket.c
index 3763f62..99982f9 100644
--- a/src/socket.c
+++ b/src/socket.c
@@ -296,6 +296,7 @@ static void start_tls_p3( conn_t *conn, int ok )
static void socket_fd_cb( int, void * );
+static void socket_connect_failed( conn_t * );
static void socket_connected2( conn_t * );
static void socket_connect_bail( conn_t * );
@@ -355,7 +356,8 @@ socket_connect( conn_t *sock, void (*cb)( int ok, void *aux
) )
he = gethostbyname( conf->host );
if (!he) {
error( "IMAP error: Cannot resolve server '%s'\n",
conf->host );
- goto bail;
+ socket_connect_bail( sock );
+ return;
}
info( "\vok\n" );
@@ -375,9 +377,8 @@ socket_connect( conn_t *sock, void (*cb)( int ok, void *aux
) )
infon( "Connecting to %s... ", sock->name );
if (connect( s, (struct sockaddr *)&addr, sizeof(addr) )) {
if (errno != EINPROGRESS) {
- sys_error( "Cannot connect to %s", sock->name );
- socket_close_internal( sock );
- goto bail;
+ socket_connect_failed( sock );
+ return;
}
conf_fd( s, 0, POLLOUT );
sock->state = SCK_CONNECTING;
@@ -389,9 +390,14 @@ socket_connect( conn_t *sock, void (*cb)( int ok, void
*aux ) )
info( "\vok\n" );
socket_connected2( sock );
return;
+}
- bail:
- socket_connect_bail( sock );
+static void
+socket_connect_failed( conn_t *conn )
+{
+ sys_error( "Cannot connect to %s", conn->name );
+ socket_close_internal( conn );
+ socket_connect_bail( conn );
}
static void
@@ -406,9 +412,7 @@ socket_connected( conn_t *conn )
}
if (soerr) {
errno = soerr;
- sys_error( "Cannot connect to %s", conn->name );
- socket_close_internal( conn );
- socket_connect_bail( conn );
+ socket_connect_failed( conn );
return;
}
socket_connected2( conn );
------------------------------------------------------------------------------
Own the Future-Intel(R) Level Up Game Demo Contest 2013
Rise to greatness in Intel's independent game demo contest. Compete
for recognition, cash, and the chance to get your game on Steam.
$5K grand prize plus 10 genre and skill prizes. Submit your demo
by 6/6/13. http://altfarm.mediaplex.com/ad/ck/12124-176961-30367-2
_______________________________________________
isync-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/isync-devel