From: Adam Dickmeiss Date: Wed, 17 Dec 2014 14:56:06 +0000 (+0100) Subject: Deal with connection creation failure X-Git-Tag: v1.12.0~11 X-Git-Url: http://lists.indexdata.dk/?a=commitdiff_plain;h=b414c6fc223434772ef8260a6f5d252e09feeaaa;p=pazpar2-moved-to-github.git Deal with connection creation failure --- 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; }