Fix the fix on unlimited connections.
authorDennis Schafroth <dennis@indexdata.com>
Thu, 6 May 2010 11:05:36 +0000 (13:05 +0200)
committerDennis Schafroth <dennis@indexdata.com>
Thu, 6 May 2010 11:09:08 +0000 (13:09 +0200)
Nice, Dennis. End-less loop.
Break out, if max_connections is not active or if we havent used more connections than max connections.

src/connection.c

index a936090..c2c5677 100644 (file)
@@ -504,22 +504,20 @@ int client_prep_connection(struct client *cl,
                         num_connections);
                 break;
             }
-            if (max_connections > 0) {
-                if (num_connections < max_connections)
-                {
-                    yaz_log(YLOG_LOG, "num_connections = %d (new); max = %d",
-                            num_connections, max_connections);
-                    break;
-                }
-                yaz_log(YLOG_LOG, "num_connections = %d (waiting) max = %d",
+            if (max_connections <= 0 || num_connections < max_connections)
+            {
+                yaz_log(YLOG_LOG, "num_connections = %d (new); max = %d",
                         num_connections, max_connections);
-                if (yaz_cond_wait(host->cond_ready, host->mutex, abstime))
-                {
-                    yaz_log(YLOG_LOG, "out of connections %s", client_get_url(cl));
-                    client_set_state(cl, Client_Error);
-                    yaz_mutex_leave(host->mutex);
-                    return 0;
-                }
+                break;
+            }
+            yaz_log(YLOG_LOG, "num_connections = %d (waiting) max = %d",
+                    num_connections, max_connections);
+            if (yaz_cond_wait(host->cond_ready, host->mutex, abstime))
+            {
+                yaz_log(YLOG_LOG, "out of connections %s", client_get_url(cl));
+                client_set_state(cl, Client_Error);
+                yaz_mutex_leave(host->mutex);
+                return 0;
             }
         }
         if (co)