+const char *Yaz_Proxy::load_balance(const char **url)
+{
+ int zurl_in_use[MAX_ZURL_PLEX];
+ Yaz_ProxyClient *c;
+ int i;
+
+ for (i = 0; i<MAX_ZURL_PLEX; i++)
+ zurl_in_use[i] = 0;
+ for (c = m_parent->m_clientPool; c; c = c->m_next)
+ {
+ for (i = 0; url[i]; i++)
+ if (!strcmp(url[i], c->get_hostname()))
+ zurl_in_use[i]++;
+ }
+ int min = 100000;
+ const char *ret = 0;
+ for (i = 0; url[i]; i++)
+ {
+ yaz_log(LOG_LOG, "%s zurl=%s use=%d",
+ m_session_str, url[i], zurl_in_use[i]);
+ if (min > zurl_in_use[i])
+ {
+ ret = url[i];
+ min = zurl_in_use[i];
+ }
+ }
+ return ret;
+}
+