From: Adam Dickmeiss Date: Wed, 3 Sep 2003 11:25:08 +0000 (+0000) Subject: Cookie can be of any length. X-Git-Tag: YAZPP.0.6~4 X-Git-Url: http://jsfdemo.indexdata.com/cgi-bin?a=commitdiff_plain;h=bf1858437c560e02a0e8073b1b33bf7de98019bb;p=yazpp-moved-to-github.git Cookie can be of any length. --- diff --git a/include/yaz++/proxy.h b/include/yaz++/proxy.h index a28601b..8e37578 100644 --- a/include/yaz++/proxy.h +++ b/include/yaz++/proxy.h @@ -2,7 +2,7 @@ * Copyright (c) 1998-2003, Index Data. * See the file LICENSE for details. * - * $Id: proxy.h,v 1.5 2003-07-25 08:57:01 adam Exp $ + * $Id: proxy.h,v 1.6 2003-09-03 11:25:08 adam Exp $ */ #include @@ -48,7 +48,7 @@ class YAZ_EXPORT Yaz_ProxyClient : public Yaz_Z_Assoc { void failNotify(); void timeoutNotify(); void connectNotify(); - char m_cookie[32]; + char *m_cookie; Yaz_ProxyClient *m_next; Yaz_ProxyClient **m_prev; int m_init_flag; diff --git a/src/yaz-proxy.cpp b/src/yaz-proxy.cpp index aa385f8..2c92327 100644 --- a/src/yaz-proxy.cpp +++ b/src/yaz-proxy.cpp @@ -2,7 +2,7 @@ * Copyright (c) 1998-2003, Index Data. * See the file LICENSE for details. * - * $Id: yaz-proxy.cpp,v 1.45 2003-07-25 08:57:01 adam Exp $ + * $Id: yaz-proxy.cpp,v 1.46 2003-09-03 11:25:08 adam Exp $ */ #include @@ -22,7 +22,7 @@ Yaz_Proxy::Yaz_Proxy(IYaz_PDU_Observable *the_PDU_Observable) : m_keepalive = 1; m_proxyTarget = 0; m_proxy_authentication = 0; - m_max_clients = 50; + m_max_clients = 100; m_seed = time(0); m_idletime = 600; m_optimize = xstrdup ("1"); @@ -124,7 +124,7 @@ Yaz_ProxyClient *Yaz_Proxy::get_client(Z_APDU *apdu) { assert (c->m_prev); assert (*c->m_prev == c); - if (!strcmp(cookie,c->m_cookie) && + if (c->m_cookie && !strcmp(cookie,c->m_cookie) && !strcmp(m_proxyTarget, c->get_hostname())) { cc = c; @@ -169,7 +169,7 @@ Yaz_ProxyClient *Yaz_Proxy::get_client(Z_APDU *apdu) { assert (c->m_prev); assert (*c->m_prev == c); - if (c->m_server == 0 && c->m_cookie[0] == 0 && + if (c->m_server == 0 && c->m_cookie == 0 && !strcmp(m_proxyTarget, c->get_hostname())) { cc = c; @@ -223,8 +223,9 @@ Yaz_ProxyClient *Yaz_Proxy::get_client(Z_APDU *apdu) yaz_log (LOG_LOG, "Existing sessions"); for (c = parent->m_clientPool; c; c = c->m_next) { - yaz_log (LOG_LOG, " Session %-3d wait=%d %s", c->m_seqno, - c->m_waiting, c->get_hostname()); + yaz_log (LOG_LOG, " Session %-3d wait=%d %s cookie=%s", c->m_seqno, + c->m_waiting, c->get_hostname(), + c->m_cookie ? c->m_cookie : ""); no_of_clients++; if (min_seq < 0 || c->m_seqno < min_seq) { @@ -247,10 +248,10 @@ Yaz_ProxyClient *Yaz_Proxy::get_client(Z_APDU *apdu) { yaz_log (LOG_LOG, "Move session %d to %d %s", c->m_seqno, parent->m_seqno, c->get_hostname()); + xfree (c->m_cookie); + c->m_cookie = 0; if (cookie) - strcpy (c->m_cookie, cookie); - else - c->m_cookie[0] = '\0'; + c->m_cookie = xstrdup(cookie); c->m_seqno = parent->m_seqno; if (c->m_server && c->m_server != this) { @@ -273,10 +274,12 @@ Yaz_ProxyClient *Yaz_Proxy::get_client(Z_APDU *apdu) parent->m_clientPool = c; c->m_prev = &parent->m_clientPool; } + + xfree (c->m_cookie); + c->m_cookie = 0; if (cookie) - strcpy (c->m_cookie, cookie); - else - c->m_cookie[0] = '\0'; + c->m_cookie = xstrdup(cookie); + yaz_log (LOG_LOG, "Connecting to %s", m_proxyTarget); c->m_seqno = parent->m_seqno; c->client(m_proxyTarget); @@ -661,6 +664,7 @@ Yaz_ProxyClient::~Yaz_ProxyClient() odr_destroy(m_init_odr); delete m_last_query; xfree (m_last_resultSetId); + xfree (m_cookie); } void Yaz_Proxy::timeoutNotify() @@ -678,7 +682,7 @@ void Yaz_ProxyClient::timeoutNotify() Yaz_ProxyClient::Yaz_ProxyClient(IYaz_PDU_Observable *the_PDU_Observable) : Yaz_Z_Assoc (the_PDU_Observable) { - m_cookie[0] = 0; + m_cookie = 0; m_next = 0; m_prev = 0; m_init_flag = 0; @@ -758,7 +762,7 @@ void Yaz_ProxyClient::recv_Z_PDU(Z_APDU *apdu) m_resultSetStartPoint = 0; } } - if (m_cookie && *m_cookie) + if (m_cookie) set_otherInformationString (apdu, VAL_COOKIE, 1, m_cookie); if (m_server) {