+ if (no_of_clients >= parent->m_max_clients)
+ {
+ c = c_min;
+ if (c->m_waiting || strcmp(m_proxyTarget, c->get_hostname()))
+ {
+ yaz_log (LOG_LOG, "Replace session %d",
+ c->m_seqno);
+ if (c->m_server && c->m_server != this)
+ delete c->m_server;
+ c->m_server = 0;
+ }
+ else
+ {
+ yaz_log (LOG_LOG, "Move session %d to %d %s",
+ c->m_seqno, parent->m_seqno, c->get_hostname());
+ if (cookie)
+ strcpy (c->m_cookie, cookie);
+ else
+ c->m_cookie[0] = '\0';
+ c->m_seqno = parent->m_seqno;
+ if (c->m_server && c->m_server != this)
+ {
+ c->m_server->m_client = 0;
+ delete c->m_server;
+ }
+ (parent->m_seqno)++;
+ yaz_log (LOG_DEBUG, "get_client 2 %p %p", this, c);
+ return c;
+ }
+ }
+ else
+ {
+ yaz_log (LOG_LOG, "Making session %d %s", parent->m_seqno,
+ m_proxyTarget);
+ c = new Yaz_ProxyClient(m_PDU_Observable->clone());
+ c->m_next = parent->m_clientPool;
+ if (c->m_next)
+ c->m_next->m_prev = &c->m_next;
+ parent->m_clientPool = c;
+ c->m_prev = &parent->m_clientPool;
+ }
+ if (cookie)
+ strcpy (c->m_cookie, cookie);
+ else
+ c->m_cookie[0] = '\0';
+ yaz_log (LOG_LOG, "Connecting to %s", m_proxyTarget);
+ c->m_seqno = parent->m_seqno;
+ c->client(m_proxyTarget);
+ c->m_init_flag = 0;
+ c->m_last_resultCount = 0;
+ c->m_last_ok = 0;
+ c->m_sr_transform = 0;
+ c->m_waiting = 0;
+ c->timeout(20);
+
+ (parent->m_seqno)++;