+void Yaz_ProxyClient::pre_init_client()
+{
+ Z_APDU *apdu = create_Z_PDU(Z_APDU_initRequest);
+ Z_InitRequest *req = apdu->u.initRequest;
+
+ ODR_MASK_SET(req->options, Z_Options_search);
+ ODR_MASK_SET(req->options, Z_Options_present);
+ ODR_MASK_SET(req->options, Z_Options_namedResultSets);
+ ODR_MASK_SET(req->options, Z_Options_triggerResourceCtrl);
+ ODR_MASK_SET(req->options, Z_Options_scan);
+ ODR_MASK_SET(req->options, Z_Options_sort);
+ ODR_MASK_SET(req->options, Z_Options_extendedServices);
+ ODR_MASK_SET(req->options, Z_Options_delSet);
+
+ ODR_MASK_SET(req->protocolVersion, Z_ProtocolVersion_1);
+ ODR_MASK_SET(req->protocolVersion, Z_ProtocolVersion_2);
+ ODR_MASK_SET(req->protocolVersion, Z_ProtocolVersion_3);
+
+ if (send_to_target(apdu) < 0)
+ {
+ delete this;
+ }
+ else
+ {
+ m_waiting = 1;
+ m_init_flag = 1;
+ }
+}
+
+void Yaz_Proxy::pre_init()
+{
+ int i;
+ const char *name = 0;
+ const char *zurl_in_use[MAX_ZURL_PLEX];
+ int limit_bw, limit_pdu, limit_req;
+ int target_idletime, client_idletime;
+ int max_clients;
+ int keepalive_limit_bw, keepalive_limit_pdu;
+ int pre_init;
+
+ Yaz_ProxyConfig *cfg = check_reconfigure();
+
+ yaz_log(LOG_LOG, "pre_init");
+ zurl_in_use[0] = 0;
+ for (i = 0; cfg && cfg->get_target_no(i, &name, zurl_in_use,
+ &limit_bw, &limit_pdu, &limit_req,
+ &target_idletime, &client_idletime,
+ &max_clients,
+ &keepalive_limit_bw,
+ &keepalive_limit_pdu,
+ &pre_init) ; i++)
+ {
+ if (pre_init)
+ {
+ int j;
+ for (j = 0; zurl_in_use[j]; j++)
+ {
+ Yaz_ProxyClient *c;
+ int spare = 0;
+ for (c = m_clientPool; c; c = c->m_next)
+ {
+ if (!strcmp(zurl_in_use[j], c->get_hostname())
+ && c->m_server == 0 && c->m_cookie == 0)
+ spare++;
+ }
+ yaz_log(LOG_LOG, "pre_init %s %s spare=%d pre_init=%d",
+ name, zurl_in_use[j], spare, pre_init);
+ if (spare < pre_init)
+ {
+ c = new Yaz_ProxyClient(m_PDU_Observable->clone(), this);
+ c->m_next = m_clientPool;
+ if (c->m_next)
+ c->m_next->m_prev = &c->m_next;
+ m_clientPool = c;
+ c->m_prev = &m_clientPool;
+
+ if (c->client(zurl_in_use[j]))
+ {
+ timeout(60);
+ delete c;
+ return;
+ }
+ c->timeout(30);
+ c->m_waiting = 1;
+ c->m_target_idletime = target_idletime;
+ yaz_log(LOG_LOG, "pre_init name=%s zurl=%s timeout=%d", name,
+ zurl_in_use[j], target_idletime);
+ c->m_seqno = m_seqno++;
+ }
+ }
+ }
+ }
+}
+