From c1106f71355e2e89dd95e8f847b1f871642344db Mon Sep 17 00:00:00 2001 From: Adam Dickmeiss Date: Fri, 30 Jan 2004 00:38:28 +0000 Subject: [PATCH] Fix HTTP Close --- src/yaz-proxy-config.cpp | 3 +-- src/yaz-proxy.cpp | 24 +++++++++--------------- src/yaz-socket-manager.cpp | 7 ++++--- 3 files changed, 14 insertions(+), 20 deletions(-) diff --git a/src/yaz-proxy-config.cpp b/src/yaz-proxy-config.cpp index 6dc8293..88449f3 100644 --- a/src/yaz-proxy-config.cpp +++ b/src/yaz-proxy-config.cpp @@ -2,7 +2,7 @@ * Copyright (c) 1998-2004, Index Data. * See the file LICENSE for details. * - * $Id: yaz-proxy-config.cpp,v 1.26 2004-01-29 21:33:39 adam Exp $ + * $Id: yaz-proxy-config.cpp,v 1.27 2004-01-30 00:38:28 adam Exp $ */ #include @@ -735,7 +735,6 @@ char *Yaz_ProxyConfig::get_explain(ODR odr, const char *name, const char *db, } } #endif - yaz_log(LOG_WARN, "No explain node"); return 0; } diff --git a/src/yaz-proxy.cpp b/src/yaz-proxy.cpp index 2700553..33a2e25 100644 --- a/src/yaz-proxy.cpp +++ b/src/yaz-proxy.cpp @@ -2,7 +2,7 @@ * Copyright (c) 1998-2004, Index Data. * See the file LICENSE for details. * - * $Id: yaz-proxy.cpp,v 1.92 2004-01-29 20:53:34 adam Exp $ + * $Id: yaz-proxy.cpp,v 1.93 2004-01-30 00:38:28 adam Exp $ */ #include @@ -706,7 +706,11 @@ int Yaz_Proxy::send_http_response(int code) Z_HTTP_Response *hres = gdu->u.HTTP_Response; if (m_http_version) hres->version = odr_strdup(o, m_http_version); - m_http_keepalive = 0; + if (m_http_keepalive) + z_HTTP_header_add(o, &hres->headers, "Connection", "Keep-Alive"); + else + timeout(0); + if (m_log_mask & PROXY_LOG_REQ_CLIENT) { yaz_log (LOG_LOG, "%sSending %s to client", m_session_str, @@ -729,6 +733,8 @@ int Yaz_Proxy::send_srw_response(Z_SRW_PDU *srw_pdu) z_HTTP_header_add(o, &hres->headers, "Content-Type", ctype); if (m_http_keepalive) z_HTTP_header_add(o, &hres->headers, "Connection", "Keep-Alive"); + else + timeout(0); static Z_SOAP_Handler soap_handlers[2] = { #if HAVE_XSLT @@ -1048,18 +1054,6 @@ int Yaz_Proxy::send_to_client(Z_APDU *apdu) m_client = 0; m_parent->pre_init(); } - if (m_http_version) - { - if (!m_http_keepalive) - { -#if 1 - timeout(1); -#else - shutdown(); - return -1; -#endif - } - } return r; } @@ -1866,8 +1860,8 @@ void Yaz_Proxy::handle_incoming_HTTP(Z_HTTP_Request *hreq) } int len = 0; Z_GDU *p = z_get_HTTP_Response(odr_encode(), 400); + timeout(0); send_GDU(p, &len); - timeout(1); } void Yaz_Proxy::handle_incoming_Z_PDU(Z_APDU *apdu) diff --git a/src/yaz-socket-manager.cpp b/src/yaz-socket-manager.cpp index 3398090..0094e1d 100644 --- a/src/yaz-socket-manager.cpp +++ b/src/yaz-socket-manager.cpp @@ -2,7 +2,7 @@ * Copyright (c) 1998-2004, Index Data. * See the file LICENSE for details. * - * $Id: yaz-socket-manager.cpp,v 1.24 2004-01-07 13:40:06 adam Exp $ + * $Id: yaz-socket-manager.cpp,v 1.25 2004-01-30 00:38:28 adam Exp $ */ #include #ifdef WIN32 @@ -179,6 +179,7 @@ int Yaz_SocketManager::processEvent() yaz_log (LOG_LOG|LOG_WARN, "select"); return -1; } + yaz_log(m_log, "select returned res=%d", res); now = time(0); for (p = m_observers; p; p = p->next) { @@ -193,7 +194,7 @@ int Yaz_SocketManager::processEvent() if (FD_ISSET(fd, &except)) mask |= YAZ_SOCKET_OBSERVE_EXCEPT; - if (mask) + if (res > 0 && mask) { YazSocketEvent *event = new YazSocketEvent; p->last_activity = now; @@ -203,7 +204,7 @@ int Yaz_SocketManager::processEvent() yaz_log (m_log, "putEvent I/O mask=%d", mask); } - else if (p->timeout && (now - p->last_activity) >= p->timeout) + else if ((now - p->last_activity) >= p->timeout) { YazSocketEvent *event = new YazSocketEvent; assert (p->last_activity); -- 1.7.10.4