Deal with connection creation failure
authorAdam Dickmeiss <adam@indexdata.dk>
Wed, 17 Dec 2014 14:56:06 +0000 (15:56 +0100)
committerAdam Dickmeiss <adam@indexdata.dk>
Wed, 17 Dec 2014 14:56:06 +0000 (15:56 +0100)
src/client.c
src/connection.c

index fbda5cd..fc167e2 100644 (file)
@@ -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);
index ec62cf5..c5fb671 100644 (file)
@@ -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;
 }