From b414c6fc223434772ef8260a6f5d252e09feeaaa Mon Sep 17 00:00:00 2001 From: Adam Dickmeiss Date: Wed, 17 Dec 2014 15:56:06 +0100 Subject: [PATCH] Deal with connection creation failure --- src/client.c | 7 ++++--- src/connection.c | 9 +++++++-- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/src/client.c b/src/client.c index fbda5cd..fc167e2 100644 --- a/src/client.c +++ b/src/client.c @@ -956,9 +956,10 @@ int client_start_search(struct client *cl) } else if (!rc_prep_connection) { - session_log(se, YLOG_LOG, "%s: postponing search: No connection", - client_get_id(cl)); - client_set_state_nb(cl, Client_Working); + client_set_diagnostic(cl, 2, + ZOOM_diag_str(2), + "Cannot create connection"); + client_set_state_nb(cl, Client_Error); return -1; } co = client_get_connection(cl); diff --git a/src/connection.c b/src/connection.c index ec62cf5..c5fb671 100644 --- a/src/connection.c +++ b/src/connection.c @@ -144,6 +144,7 @@ static struct connection *connection_create(struct client *cl, iochan_man_t iochan_man) { struct connection *co; + int ret; co = xmalloc(sizeof(*co)); @@ -159,9 +160,13 @@ static struct connection *connection_create(struct client *cl, co->operation_timeout = operation_timeout; co->session_timeout = session_timeout; - connection_connect(co, iochan_man); - + ret = connection_connect(co, iochan_man); connection_use(1); + if (ret) + { /* error */ + connection_destroy(co); + co = 0; + } return co; } -- 1.7.10.4