X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=src%2Ffilter_frontend_net.cpp;h=2e2ada228645ba4bf1371bf8f92eaa870bc15bfa;hb=1fe3038c15740cf21a2eb7b00edad8d216384c2e;hp=f7b1bbb7019051f4b6eb33feafa1f115e38e1e00;hpb=cabf4d45007436abe46147df5da77901ea39238b;p=metaproxy-moved-to-github.git diff --git a/src/filter_frontend_net.cpp b/src/filter_frontend_net.cpp index f7b1bbb..2e2ada2 100644 --- a/src/filter_frontend_net.cpp +++ b/src/filter_frontend_net.cpp @@ -1,5 +1,5 @@ /* This file is part of Metaproxy. - Copyright (C) 2005-2012 Index Data + Copyright (C) Index Data Metaproxy is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free @@ -18,6 +18,9 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #include "config.hpp" +#if HAVE_GETRLIMIT +#include +#endif #include #include #include @@ -32,7 +35,9 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #include #include #include +#include #include "gduutil.hpp" +#include #include @@ -46,17 +51,34 @@ namespace metaproxy_1 { friend class FrontendNet; std::string port; std::string route; + std::string cert_fname; + int max_recv_bytes; }; class FrontendNet::Rep { friend class FrontendNet; + int m_no_threads; + int m_max_threads; + int m_stack_size; std::vector m_ports; int m_listen_duration; int m_session_timeout; int m_connect_max; + int m_http_req_max; std::string m_msg_config; + std::string m_stat_req; yazpp_1::SocketManager mySocketManager; ZAssocServer **az; + yazpp_1::PDU_Assoc **pdu; + int m_duration_freq[22]; + double m_duration_lim[22]; + double m_duration_max; + double m_duration_min; + double m_duration_total; + int m_stop_signo; + public: + Rep(); + ~Rep(); }; class FrontendNet::My_Timer_Thread : public yazpp_1::ISocketObserver { private: @@ -74,16 +96,17 @@ namespace metaproxy_1 { ZAssocChild(yazpp_1::IPDU_Observable *the_PDU_Observable, mp::ThreadPoolSocketObserver *m_thread_pool_observer, const mp::Package *package, - std::string route, - const char *msg_config); + Port *port, + Rep *rep, + yazpp_1::LimitConnect &limit_connect); int m_no_requests; - std::string m_route; + Port *m_port; private: yazpp_1::IPDU_Observer* sessionNotify( yazpp_1::IPDU_Observable *the_PDU_Observable, int fd); void recv_GDU(Z_GDU *apdu, int len); - + void report(Z_HTTP_Request *hreq); void failNotify(); void timeoutNotify(); void connectNotify(); @@ -93,13 +116,14 @@ namespace metaproxy_1 { mp::Origin m_origin; bool m_delete_flag; const mp::Package *m_package; - const char *m_msg_config; + Rep *m_p; + yazpp_1::LimitConnect &m_limit_connect; }; class FrontendNet::ThreadPoolPackage : public mp::IThreadPoolMsg { public: ThreadPoolPackage(mp::Package *package, yf::FrontendNet::ZAssocChild *ses, - const char *msg_config); + Rep *rep); ~ThreadPoolPackage(); IThreadPoolMsg *handle(); void result(const char *t_info); @@ -108,46 +132,41 @@ namespace metaproxy_1 { yaz_timing_t timer; ZAssocChild *m_assoc_child; mp::Package *m_package; - const char *m_msg_config; - }; + Rep *m_p; + }; class FrontendNet::ZAssocServer : public yazpp_1::Z_Assoc { public: ~ZAssocServer(); - ZAssocServer(yazpp_1::IPDU_Observable *PDU_Observable, int timeout, - int connect_max, std::string route, - const char *msg_config); + ZAssocServer(yazpp_1::IPDU_Observable *PDU_Observable, + FrontendNet::Port *port, + Rep *rep); void set_package(const mp::Package *package); - void set_thread_pool(ThreadPoolSocketObserver *m_thread_pool_observer); + void set_thread_pool(ThreadPoolSocketObserver *observer); private: yazpp_1::IPDU_Observer* sessionNotify( yazpp_1::IPDU_Observable *the_PDU_Observable, int fd); void recv_GDU(Z_GDU *apdu, int len); - + void failNotify(); void timeoutNotify(); void connectNotify(); private: mp::ThreadPoolSocketObserver *m_thread_pool_observer; const mp::Package *m_package; - int m_session_timeout; - int m_connect_max; yazpp_1::LimitConnect limit_connect; - std::string m_route; - const char *m_msg_config; + Port *m_port; + Rep *m_p; }; } } yf::FrontendNet::ThreadPoolPackage::ThreadPoolPackage(mp::Package *package, ZAssocChild *ses, - const char *msg_config) : - m_assoc_child(ses), m_package(package), m_msg_config(msg_config) + Rep *rep) : + m_assoc_child(ses), m_package(package), m_p(rep) { - if (msg_config) - timer = yaz_timing_create(); - else - timer = 0; + timer = yaz_timing_create(); } yf::FrontendNet::ThreadPoolPackage::~ThreadPoolPackage() @@ -173,6 +192,39 @@ void yf::FrontendNet::ThreadPoolPackage::result(const char *t_info) { int len; m_assoc_child->send_GDU(gdu->get(), &len); + + yaz_timing_stop(timer); + double duration = yaz_timing_get_real(timer); + + size_t ent = 0; + while (m_p->m_duration_lim[ent] != 0.0 && duration > m_p->m_duration_lim[ent]) + ent++; + m_p->m_duration_freq[ent]++; + + m_p->m_duration_total += duration; + + if (m_p->m_duration_max < duration) + m_p->m_duration_max = duration; + + if (m_p->m_duration_min == 0.0 || m_p->m_duration_min > duration) + m_p->m_duration_min = duration; + + if (m_p->m_msg_config.length()) + { + Z_GDU *z_gdu = gdu->get(); + + std::ostringstream os; + os << m_p->m_msg_config << " " + << *m_package << " " + << std::fixed << std::setprecision (6) << duration << " "; + + if (z_gdu) + os << *z_gdu; + else + os << "-"; + + yaz_log(YLOG_LOG, "%s %s", os.str().c_str(), t_info); + } } else if (!m_package->session().is_closed()) { @@ -186,7 +238,7 @@ void yf::FrontendNet::ThreadPoolPackage::result(const char *t_info) mp::odr odr; int len; Z_APDU *apdu_response = odr.create_close( - z_gdu->u.z3950, Z_Close_systemProblem, + z_gdu->u.z3950, Z_Close_systemProblem, "unhandled Z39.50 request"); m_assoc_child->send_Z_PDU(apdu_response, &len); @@ -196,8 +248,8 @@ void yf::FrontendNet::ThreadPoolPackage::result(const char *t_info) // For HTTP, respond with Server Error int len; mp::odr odr; - Z_GDU *zgdu_res - = odr.create_HTTP_Response(m_package->session(), + Z_GDU *zgdu_res + = odr.create_HTTP_Response(m_package->session(), z_gdu->u.HTTP_Request, 500); m_assoc_child->send_GDU(zgdu_res, &len); } @@ -209,58 +261,48 @@ void yf::FrontendNet::ThreadPoolPackage::result(const char *t_info) m_assoc_child->close(); } - if (m_msg_config) - { - yaz_timing_stop(timer); - double duration = yaz_timing_get_real(timer); - Z_GDU *z_gdu = gdu->get(); - - std::ostringstream os; - os << m_msg_config << " " - << *m_package << " " - << std::fixed << std::setprecision (6) << duration << " "; - - if (z_gdu) - os << *z_gdu; - else - os << "-"; - - yaz_log(YLOG_LOG, "%s %s", os.str().c_str(), t_info); - } delete this; } -mp::IThreadPoolMsg *yf::FrontendNet::ThreadPoolPackage::handle() +mp::IThreadPoolMsg *yf::FrontendNet::ThreadPoolPackage::handle() { - m_package->move(m_assoc_child->m_route); + m_package->move(m_assoc_child->m_port->route); return this; } - yf::FrontendNet::ZAssocChild::ZAssocChild( yazpp_1::IPDU_Observable *PDU_Observable, mp::ThreadPoolSocketObserver *my_thread_pool, const mp::Package *package, - std::string route, - const char *msg_config) - : Z_Assoc(PDU_Observable), m_msg_config(msg_config) + Port *port, Rep *rep, + yazpp_1::LimitConnect &limit_connect) + : Z_Assoc(PDU_Observable), m_p(rep), m_limit_connect(limit_connect) { m_thread_pool_observer = my_thread_pool; m_no_requests = 0; m_delete_flag = false; m_package = package; - m_route = route; + m_port = port; const char *peername = PDU_Observable->getpeername(); if (!peername) peername = "unknown"; - m_origin.set_tcpip_address(std::string(peername), m_session.id()); + else + { + const char *cp = strchr(peername, ':'); + if (cp) + peername = cp + 1; + } + std::string addr; + addr.append(peername); + addr.append(" "); + addr.append(port->port); + m_origin.set_tcpip_address(addr, m_session.id()); + timeout(m_p->m_session_timeout); } - yazpp_1::IPDU_Observer *yf::FrontendNet::ZAssocChild::sessionNotify( - yazpp_1::IPDU_Observable - *the_PDU_Observable, int fd) + yazpp_1::IPDU_Observable *the_PDU_Observable, int fd) { return 0; } @@ -269,29 +311,124 @@ yf::FrontendNet::ZAssocChild::~ZAssocChild() { } +void yf::FrontendNet::ZAssocChild::report(Z_HTTP_Request *hreq) +{ + mp::odr o; + + Z_GDU *gdu_res = o.create_HTTP_Response(m_session, hreq, 200); + + Z_HTTP_Response *hres = gdu_res->u.HTTP_Response; + + mp::wrbuf w; + size_t i; + int number_total = 0; + + for (i = 0; m_p->m_duration_lim[i] != 0.0; i++) + number_total += m_p->m_duration_freq[i]; + number_total += m_p->m_duration_freq[i]; + + wrbuf_puts(w, "\n"); + wrbuf_puts(w, "\n"); + wrbuf_printf(w, " \n", number_total); + for (i = 0; m_p->m_duration_lim[i] != 0.0; i++) + { + if (m_p->m_duration_freq[i] > 0) + wrbuf_printf( + w, " \n", + i > 0 ? m_p->m_duration_lim[i - 1] : 0.0, + m_p->m_duration_lim[i], m_p->m_duration_freq[i]); + } + + if (m_p->m_duration_freq[i] > 0) + wrbuf_printf( + w, " \n", + m_p->m_duration_lim[i - 1], m_p->m_duration_freq[i]); + + if (m_p->m_duration_max != 0.0) + wrbuf_printf( + w, " \n", + m_p->m_duration_max); + if (m_p->m_duration_min != 0.0) + wrbuf_printf( + w, " \n", + m_p->m_duration_min); + if (m_p->m_duration_total != 0.0) + wrbuf_printf( + w, " \n", + m_p->m_duration_total / number_total); + + wrbuf_puts(w, " \n"); + + int thread_busy; + int thread_total; + m_thread_pool_observer->get_thread_info(thread_busy, thread_total); + + wrbuf_printf(w, " \n", + thread_busy, thread_total); + + wrbuf_puts(w, "\n"); + + hres->content_len = w.len(); + hres->content_buf = (char *) w.buf(); + + int len; + send_GDU(gdu_res, &len); +} + void yf::FrontendNet::ZAssocChild::recv_GDU(Z_GDU *z_pdu, int len) { m_no_requests++; mp::Package *p = new mp::Package(m_session, m_origin); - ThreadPoolPackage *tp = new ThreadPoolPackage(p, this, m_msg_config); + if (z_pdu && z_pdu->which == Z_GDU_HTTP_Request) + { + Z_HTTP_Request *hreq = z_pdu->u.HTTP_Request; + + const char *f = z_HTTP_header_lookup(hreq->headers, "X-Forwarded-For"); + if (f) + p->origin().set_tcpip_address(std::string(f), m_session.id()); + + if (m_p->m_stat_req.length() + && !strcmp(hreq->path, m_p->m_stat_req.c_str())) + { + report(hreq); + return; + } + std::string peername = p->origin().get_address(); + + m_limit_connect.add_connect(peername.c_str()); + m_limit_connect.cleanup(false); + int con_sz = m_limit_connect.get_total(peername.c_str()); + + if (m_p->m_http_req_max && con_sz >= m_p->m_http_req_max) + { + mp::odr o; + Z_GDU *gdu_res = o.create_HTTP_Response(m_session, hreq, 500); + int len; + send_GDU(gdu_res, &len); + return; + } + } + + ThreadPoolPackage *tp = new ThreadPoolPackage(p, this, m_p); p->copy_route(*m_package); p->request() = yazpp_1::GDU(z_pdu); - if (m_msg_config) + if (m_p->m_msg_config.length()) { - if (z_pdu) + if (z_pdu) { std::ostringstream os; - os << m_msg_config << " " + os << m_p->m_msg_config << " " << *p << " " - << "0.000000" << " " + << "0.000000" << " " << *z_pdu; yaz_log(YLOG_LOG, "%s", os.str().c_str()); } } - m_thread_pool_observer->put(tp); + m_thread_pool_observer->put(tp); } void yf::FrontendNet::ZAssocChild::failNotify() @@ -309,7 +446,7 @@ void yf::FrontendNet::ZAssocChild::failNotify() mp::Package *p = new mp::Package(m_session, m_origin); - ThreadPoolPackage *tp = new ThreadPoolPackage(p, this, m_msg_config); + ThreadPoolPackage *tp = new ThreadPoolPackage(p, this, m_p); p->copy_route(*m_package); m_thread_pool_observer->cleanup(tp, &m_session); m_thread_pool_observer->put(tp); @@ -327,11 +464,10 @@ void yf::FrontendNet::ZAssocChild::connectNotify() yf::FrontendNet::ZAssocServer::ZAssocServer( yazpp_1::IPDU_Observable *PDU_Observable, - int timeout, int connect_max, - std::string route, const char *msg_config) - : - Z_Assoc(PDU_Observable), m_session_timeout(timeout), - m_connect_max(connect_max), m_route(route), m_msg_config(msg_config) + Port *port, + Rep *rep) + : + Z_Assoc(PDU_Observable), m_port(port), m_p(rep) { m_package = 0; } @@ -342,13 +478,14 @@ void yf::FrontendNet::ZAssocServer::set_package(const mp::Package *package) m_package = package; } -void yf::FrontendNet::ZAssocServer::set_thread_pool(ThreadPoolSocketObserver *observer) +void yf::FrontendNet::ZAssocServer::set_thread_pool( + mp::ThreadPoolSocketObserver *observer) { m_thread_pool_observer = observer; } -yazpp_1::IPDU_Observer *yf::FrontendNet::ZAssocServer::sessionNotify(yazpp_1::IPDU_Observable - *the_PDU_Observable, int fd) +yazpp_1::IPDU_Observer *yf::FrontendNet::ZAssocServer::sessionNotify( + yazpp_1::IPDU_Observable *the_PDU_Observable, int fd) { const char *peername = the_PDU_Observable->getpeername(); @@ -357,13 +494,12 @@ yazpp_1::IPDU_Observer *yf::FrontendNet::ZAssocServer::sessionNotify(yazpp_1::IP limit_connect.add_connect(peername); limit_connect.cleanup(false); int con_sz = limit_connect.get_total(peername); - if (m_connect_max && con_sz > m_connect_max) + if (m_p->m_connect_max && con_sz > m_p->m_connect_max) return 0; } ZAssocChild *my = new ZAssocChild(the_PDU_Observable, m_thread_pool_observer, - m_package, m_route, m_msg_config); - my->timeout(m_session_timeout); + m_package, m_port, m_p, limit_connect); return my; } @@ -389,33 +525,77 @@ void yf::FrontendNet::ZAssocServer::connectNotify() yf::FrontendNet::FrontendNet() : m_p(new Rep) { - m_p->m_no_threads = 5; - m_p->m_listen_duration = 0; - m_p->m_session_timeout = 300; // 5 minutes - m_p->m_connect_max = 0; - m_p->az = 0; } -yf::FrontendNet::~FrontendNet() +yf::FrontendNet::Rep::Rep() { - if (m_p->az) + m_max_threads = m_no_threads = 5; + m_stack_size = 0; + m_listen_duration = 0; + m_session_timeout = 300; // 5 minutes + m_connect_max = 0; + az = 0; + size_t i; + for (i = 0; i < 22; i++) + m_duration_freq[i] = 0; + m_duration_lim[0] = 0.000001; + m_duration_lim[1] = 0.00001; + m_duration_lim[2] = 0.0001; + m_duration_lim[3] = 0.001; + m_duration_lim[4] = 0.01; + m_duration_lim[5] = 0.1; + m_duration_lim[6] = 0.2; + m_duration_lim[7] = 0.3; + m_duration_lim[8] = 0.5; + m_duration_lim[9] = 1.0; + m_duration_lim[10] = 1.5; + m_duration_lim[11] = 2.0; + m_duration_lim[12] = 3.0; + m_duration_lim[13] = 4.0; + m_duration_lim[14] = 5.0; + m_duration_lim[15] = 6.0; + m_duration_lim[16] = 8.0; + m_duration_lim[17] = 10.0; + m_duration_lim[18] = 15.0; + m_duration_lim[19] = 20.0; + m_duration_lim[20] = 30.0; + m_duration_lim[21] = 0.0; + m_duration_max = 0.0; + m_duration_min = 0.0; + m_duration_total = 0.0; + m_stop_signo = 0; +} + +yf::FrontendNet::Rep::~Rep() +{ + if (az) { size_t i; - for (i = 0; im_ports.size(); i++) - delete m_p->az[i]; - delete [] m_p->az; + for (i = 0; i < m_ports.size(); i++) + delete az[i]; + delete [] az; + delete [] pdu; } - m_p->az = 0; + az = 0; } -void yf::FrontendNet::stop() const +yf::FrontendNet::~FrontendNet() { - if (m_p->az) - { - size_t i; - for (i = 0; im_ports.size(); i++) - m_p->az[i]->server(""); - } +} + +void yf::FrontendNet::stop(int signo) const +{ + m_p->m_stop_signo = signo; +} + +void yf::FrontendNet::start() const +{ +#if HAVE_GETRLIMIT + struct rlimit limit_data; + getrlimit(RLIMIT_NOFILE, &limit_data); + yaz_log(YLOG_LOG, "getrlimit NOFILE cur=%ld max=%ld", + (long) limit_data.rlim_cur, (long) limit_data.rlim_max); +#endif } bool yf::FrontendNet::My_Timer_Thread::timeout() @@ -425,7 +605,7 @@ bool yf::FrontendNet::My_Timer_Thread::timeout() yf::FrontendNet::My_Timer_Thread::My_Timer_Thread( yazpp_1::ISocketObservable *obs, - int duration) : + int duration) : m_obs(obs), m_pipe(9123), m_timeout(false) { obs->addObserver(m_pipe.read_fd(), this); @@ -439,7 +619,7 @@ void yf::FrontendNet::My_Timer_Thread::socketNotify(int event) m_obs->deleteObserver(this); } -void yf::FrontendNet::process(Package &package) const +void yf::FrontendNet::process(mp::Package &package) const { if (m_p->az == 0) return; @@ -449,8 +629,10 @@ void yf::FrontendNet::process(Package &package) const if (m_p->m_listen_duration) tt = new My_Timer_Thread(&m_p->mySocketManager, m_p->m_listen_duration); - - ThreadPoolSocketObserver tp(&m_p->mySocketManager, m_p->m_no_threads); + + ThreadPoolSocketObserver tp(&m_p->mySocketManager, m_p->m_no_threads, + m_p->m_max_threads, + m_p->m_stack_size); for (i = 0; im_ports.size(); i++) { @@ -459,6 +641,35 @@ void yf::FrontendNet::process(Package &package) const } while (m_p->mySocketManager.processEvent() > 0) { + if (m_p->m_stop_signo == SIGTERM) + { + yaz_log(YLOG_LOG, "metaproxy received SIGTERM"); + if (m_p->az) + { + size_t i; + for (i = 0; i < m_p->m_ports.size(); i++) + { + m_p->pdu[i]->shutdown(); + m_p->az[i]->server(""); + } + yaz_daemon_stop(); + } + break; /* stop right away */ + } +#ifndef WIN32 + if (m_p->m_stop_signo == SIGUSR1) + { /* just stop listeners and cont till all sessions are done*/ + yaz_log(YLOG_LOG, "metaproxy received SIGUSR1"); + m_p->m_stop_signo = 0; + if (m_p->az) + { + size_t i; + for (i = 0; i < m_p->m_ports.size(); i++) + m_p->az[i]->server(""); + yaz_daemon_stop(); + } + } +#endif int no = m_p->mySocketManager.getNumberOfObservers(); if (no <= 1) break; @@ -483,31 +694,57 @@ void yf::FrontendNet::configure(const xmlNode * ptr, bool test_only, if (!strcmp((const char *) ptr->name, "port")) { Port port; - const struct _xmlAttr *attr; - for (attr = ptr->properties; attr; attr = attr->next) - { - if (!strcmp((const char *) attr->name, "route")) - port.route = mp::xml::get_text(attr); - } - port.port = mp::xml::get_text(ptr); + + const char *names[5] = {"route", "max_recv_bytes", "port", + "cert_fname", 0}; + std::string values[4]; + + mp::xml::parse_attr(ptr, names, values); + port.route = values[0]; + if (values[1].length() > 0) + port.max_recv_bytes = atoi(values[1].c_str()); + else + port.max_recv_bytes = 0; + if (values[2].length() > 0) + port.port = values[2]; + else + port.port = mp::xml::get_text(ptr); + port.cert_fname = values[3]; ports.push_back(port); - } else if (!strcmp((const char *) ptr->name, "threads")) { std::string threads_str = mp::xml::get_text(ptr); int threads = atoi(threads_str.c_str()); if (threads < 1) - throw yf::FilterException("Bad value for threads: " + throw yf::FilterException("Bad value for threads: " + threads_str); m_p->m_no_threads = threads; } + else if (!strcmp((const char *) ptr->name, "max-threads")) + { + std::string threads_str = mp::xml::get_text(ptr); + int threads = atoi(threads_str.c_str()); + if (threads < 1) + throw yf::FilterException("Bad value for max-threads: " + + threads_str); + m_p->m_max_threads = threads; + } + else if (!strcmp((const char *) ptr->name, "stack-size")) + { + std::string sz_str = mp::xml::get_text(ptr); + int sz = atoi(sz_str.c_str()); + if (sz < 0) + throw yf::FilterException("Bad value for stack-size: " + + sz_str); + m_p->m_stack_size = sz * 1024; + } else if (!strcmp((const char *) ptr->name, "timeout")) { std::string timeout_str = mp::xml::get_text(ptr); int timeout = atoi(timeout_str.c_str()); if (timeout < 1) - throw yf::FilterException("Bad value for timeout: " + throw yf::FilterException("Bad value for timeout: " + timeout_str); m_p->m_session_timeout = timeout; } @@ -515,13 +752,21 @@ void yf::FrontendNet::configure(const xmlNode * ptr, bool test_only, { m_p->m_connect_max = mp::xml::get_int(ptr, 0); } + else if (!strcmp((const char *) ptr->name, "http-req-max")) + { + m_p->m_http_req_max = mp::xml::get_int(ptr, 0); + } else if (!strcmp((const char *) ptr->name, "message")) { m_p->m_msg_config = mp::xml::get_text(ptr); } + else if (!strcmp((const char *) ptr->name, "stat-req")) + { + m_p->m_stat_req = mp::xml::get_text(ptr); + } else { - throw yf::FilterException("Bad element " + throw yf::FilterException("Bad element " + std::string((const char *) ptr->name)); } @@ -551,28 +796,35 @@ void yf::FrontendNet::set_ports(std::vector &ports) void yf::FrontendNet::set_ports(std::vector &ports) { m_p->m_ports = ports; - + m_p->az = new yf::FrontendNet::ZAssocServer *[m_p->m_ports.size()]; - + m_p->pdu = new yazpp_1::PDU_Assoc *[m_p->m_ports.size()]; + // Create yf::FrontendNet::ZAssocServer for each port size_t i; - for (i = 0; im_ports.size(); i++) + for (i = 0; i < m_p->m_ports.size(); i++) + m_p->az[i] = 0; + for (i = 0; i < m_p->m_ports.size(); i++) { // create a PDU assoc object (one per yf::FrontendNet::ZAssocServer) yazpp_1::PDU_Assoc *as = new yazpp_1::PDU_Assoc(&m_p->mySocketManager); - + + if (m_p->m_ports[i].cert_fname.length()) + as->set_cert_fname(m_p->m_ports[i].cert_fname.c_str()); // create ZAssoc with PDU Assoc - m_p->az[i] = new yf::FrontendNet::ZAssocServer(as, - m_p->m_session_timeout, - m_p->m_connect_max, - m_p->m_ports[i].route, - m_p->m_msg_config.length() > 0 ? - m_p->m_msg_config.c_str() : 0); + m_p->pdu[i] = as; + m_p->az[i] = new yf::FrontendNet::ZAssocServer( + as, &m_p->m_ports[i], m_p.get()); if (m_p->az[i]->server(m_p->m_ports[i].port.c_str())) { - throw yf::FilterException("Unable to bind to address " + throw yf::FilterException("Unable to bind to address " + std::string(m_p->m_ports[i].port)); } + COMSTACK cs = as->get_comstack(); + + if (cs && m_p->m_ports[i].max_recv_bytes) + cs_set_max_recv_bytes(cs, m_p->m_ports[i].max_recv_bytes); + } }