For sort, re-use non-idle clients
[pazpar2-moved-to-github.git] / src / connection.c
index e441514..02509cf 100644 (file)
@@ -496,7 +496,8 @@ static int connection_connect(struct connection *con, iochan_man_t iochan_man)
 int client_prep_connection(struct client *cl,
                            int operation_timeout, int session_timeout,
                            iochan_man_t iochan_man,
-                           const struct timeval *abstime)
+                           const struct timeval *abstime,
+                           int ok_with_working)
 {
     struct connection *co;
     struct session_database *sdb = client_get_database(cl);
@@ -525,7 +526,8 @@ int client_prep_connection(struct client *cl,
     if (co)
     {
         assert(co->host);
-        if (co->host == host && client_get_state(cl) == Client_Idle)
+        if (co->host == host && (client_get_state(cl) == Client_Idle
+                                 || ok_with_working))
         {
             return 2;
         }