From: Adam Dickmeiss Date: Thu, 11 Jun 2009 11:51:06 +0000 (+0200) Subject: Fix GCC warnings. Set imp name/version for init response X-Git-Tag: v1.0.17~4 X-Git-Url: http://sru.miketaylor.org.uk/cgi-bin?a=commitdiff_plain;h=dfea092810f0735486a91bdb42d47cc9e9c3bc5a;p=metaproxy-moved-to-github.git Fix GCC warnings. Set imp name/version for init response --- diff --git a/src/ex_filter_frontend_net.cpp b/src/ex_filter_frontend_net.cpp index f9a4ef4..c5e4da6 100644 --- a/src/ex_filter_frontend_net.cpp +++ b/src/ex_filter_frontend_net.cpp @@ -55,7 +55,7 @@ public: "Content-Type", "text/plain"); http_res->content_buf = - odr_strdup(odr, "Welcome to YP2"); + odr_strdup(odr, "Welcome to Metaproxy"); http_res->content_len = strlen(http_res->content_buf); package.response() = gdu; diff --git a/src/filter_backend_test.cpp b/src/filter_backend_test.cpp index 7881e57..2ad6424 100644 --- a/src/filter_backend_test.cpp +++ b/src/filter_backend_test.cpp @@ -44,6 +44,8 @@ namespace metaproxy_1 { namespace filter { class Session_info { int dummy; + public: + Session_info() { dummy = 0; }; }; class BackendTest::Rep { friend class BackendTest; diff --git a/src/metaproxy_prog.cpp b/src/metaproxy_prog.cpp index 47f84ab..4cba424 100644 --- a/src/metaproxy_prog.cpp +++ b/src/metaproxy_prog.cpp @@ -144,8 +144,11 @@ static int sc_main( return 1; } // and perform Xinclude then - if (xmlXIncludeProcess(doc) > 0) { - yaz_log (YLOG_LOG, "processing XInclude directive"); + int r = xmlXIncludeProcess(doc); + if (r == -1) + { + yaz_log(YLOG_FATAL, "XInclude processing failed"); + return 1; } mp::FactoryStatic factory; mp::RouterFleXML router(doc, factory, false); @@ -159,11 +162,11 @@ static int sc_main( return 1; } catch (std::runtime_error &e) { - yaz_log (YLOG_FATAL, "std::runtime error: %s" , e.what() ); + yaz_log(YLOG_FATAL, "std::runtime error: %s" , e.what() ); return 1; } catch ( ... ) { - yaz_log (YLOG_FATAL, "Unknown Exception"); + yaz_log(YLOG_FATAL, "Unknown Exception"); return 1; } return 0; diff --git a/src/sru_util.cpp b/src/sru_util.cpp index 45e5823..7a96b8d 100644 --- a/src/sru_util.cpp +++ b/src/sru_util.cpp @@ -158,11 +158,11 @@ bool mp_util::build_sru_explain(metaproxy_1::Package &package, bool mp_util::build_sru_response(mp::Package &package, - mp::odr &odr_en, - Z_SOAP *soap, - const Z_SRW_PDU *sru_pdu_res, - char *charset, - const char *stylesheet) + mp::odr &odr_en, + Z_SOAP *soap, + const Z_SRW_PDU *sru_pdu_res, + char *charset, + const char *stylesheet) { // SRU request package translation to Z3950 package @@ -185,7 +185,8 @@ bool mp_util::build_sru_response(mp::Package &package, //http_res->code = http_code; std::string ctype("text/xml"); - if (charset){ + if (charset) + { ctype += "; charset="; ctype += charset; } @@ -195,13 +196,10 @@ bool mp_util::build_sru_response(mp::Package &package, // packaging Z_SOAP into HTML response static Z_SOAP_Handler soap_handlers[4] = { - {"http://www.loc.gov/zing/srw/", 0, - (Z_SOAP_fun) yaz_srw_codec}, - {"http://www.loc.gov/zing/srw/v1.0/", 0, - (Z_SOAP_fun) yaz_srw_codec}, - {"http://www.loc.gov/zing/srw/update/", 0, - (Z_SOAP_fun) yaz_ucp_codec}, - {0, 0, 0} + {(char *)YAZ_XMLNS_SRU_v1_1, 0, (Z_SOAP_fun) yaz_srw_codec}, + {(char *)YAZ_XMLNS_SRU_v1_0, 0, (Z_SOAP_fun) yaz_srw_codec}, + {(char *)YAZ_XMLNS_UPDATE_v0_9, 0, (Z_SOAP_fun) yaz_ucp_codec}, + {0, 0, 0} }; diff --git a/src/test_filter_auth_simple.cpp b/src/test_filter_auth_simple.cpp index f939858..e057842 100644 --- a/src/test_filter_auth_simple.cpp +++ b/src/test_filter_auth_simple.cpp @@ -43,14 +43,11 @@ public: } Z_GDU *gdu = package.request().get(); - if (gdu) + if (gdu && gdu->which == Z_GDU_Z3950) { // std::cout << "Got PDU. Sending init response\n"; mp::odr odr; - Z_APDU *apdu = zget_APDU(odr, Z_APDU_initResponse); - - apdu->u.initResponse->implementationName = "YP2/YAZ"; - + Z_APDU *apdu = odr.create_initResponse(gdu->u.z3950, 0, 0); package.response() = apdu; } package.move(); diff --git a/src/test_filter_frontend_net.cpp b/src/test_filter_frontend_net.cpp index 16cbe4e..df80938 100644 --- a/src/test_filter_frontend_net.cpp +++ b/src/test_filter_frontend_net.cpp @@ -44,14 +44,11 @@ public: } Z_GDU *gdu = package.request().get(); - if (gdu) + if (gdu && gdu->which == Z_GDU_Z3950) { // std::cout << "Got PDU. Sending init response\n"; mp::odr odr; - Z_APDU *apdu = zget_APDU(odr, Z_APDU_initResponse); - - apdu->u.initResponse->implementationName = "YP2/YAZ"; - + Z_APDU *apdu = odr.create_initResponse(gdu->u.z3950, 0, 0); package.response() = apdu; } return package.move(); diff --git a/src/test_filter_log.cpp b/src/test_filter_log.cpp index a14b827..db02fb7 100644 --- a/src/test_filter_log.cpp +++ b/src/test_filter_log.cpp @@ -43,14 +43,11 @@ public: } Z_GDU *gdu = package.request().get(); - if (gdu) + if (gdu && gdu->which == Z_GDU_Z3950) { // std::cout << "Got PDU. Sending init response\n"; mp::odr odr; - Z_APDU *apdu = zget_APDU(odr, Z_APDU_initResponse); - - apdu->u.initResponse->implementationName = "YP2/YAZ"; - + Z_APDU *apdu = odr.create_initResponse(gdu->u.z3950, 0, 0); package.response() = apdu; } return package.move(); diff --git a/src/test_filter_multi.cpp b/src/test_filter_multi.cpp index 710bafd..d441d4a 100644 --- a/src/test_filter_multi.cpp +++ b/src/test_filter_multi.cpp @@ -43,14 +43,11 @@ public: } Z_GDU *gdu = package.request().get(); - if (gdu) + if (gdu && gdu->which == Z_GDU_Z3950) { // std::cout << "Got PDU. Sending init response\n"; mp::odr odr; - Z_APDU *apdu = zget_APDU(odr, Z_APDU_initResponse); - - apdu->u.initResponse->implementationName = "YP2/YAZ"; - + Z_APDU *apdu = odr.create_initResponse(gdu->u.z3950, 0, 0); package.response() = apdu; } package.move(); diff --git a/src/test_session2.cpp b/src/test_session2.cpp index 13c4890..394e3c9 100644 --- a/src/test_session2.cpp +++ b/src/test_session2.cpp @@ -38,7 +38,7 @@ class Worker { public: Worker(int nr = 0) - : m_nr(nr){}; + : m_nr(nr), m_id(0) {}; void operator() (void) { for (int i=0; i < 100; ++i) diff --git a/src/thread_pool_observer.cpp b/src/thread_pool_observer.cpp index 64ddc62..e473c1a 100644 --- a/src/thread_pool_observer.cpp +++ b/src/thread_pool_observer.cpp @@ -124,7 +124,16 @@ void ThreadPoolSocketObserver::socketNotify(int event) #ifdef WIN32 recv(m_p->m_pipe.read_fd(), buf, 1, 0); #else - read(m_p->m_pipe.read_fd(), buf, 1); + ssize_t r = read(m_p->m_pipe.read_fd(), buf, 1); + if (r != 1) + { + if (r == (ssize_t) (-1)) + yaz_log(YLOG_WARN|YLOG_ERRNO, + "ThreadPoolSocketObserver::socketNotify. read fail"); + else + yaz_log(YLOG_WARN, + "ThreadPoolSocketObserver::socketNotify. read returned 0"); + } #endif IThreadPoolMsg *out; { @@ -160,7 +169,16 @@ void ThreadPoolSocketObserver::run(void *p) #ifdef WIN32 send(m_p->m_pipe.write_fd(), "", 1, 0); #else - write(m_p->m_pipe.write_fd(), "", 1); + ssize_t r = write(m_p->m_pipe.write_fd(), "", 1); + if (r != 1) + { + if (r == (ssize_t) (-1)) + yaz_log(YLOG_WARN|YLOG_ERRNO, + "ThreadPoolSocketObserver::run. write fail"); + else + yaz_log(YLOG_WARN, + "ThreadPoolSocketObserver::run. write returned 0"); + } #endif } } diff --git a/src/util.cpp b/src/util.cpp index 6482063..7676d06 100644 --- a/src/util.cpp +++ b/src/util.cpp @@ -478,6 +478,13 @@ Z_APDU *mp::odr::create_initResponse(const Z_APDU *in_apdu, zget_init_diagnostics(m_odr, error, addinfo); *apdu->u.initResponse->result = 0; } + apdu->u.initResponse->implementationName = + odr_prepend(m_odr, "Metaproxy", + apdu->u.initResponse->implementationName); + apdu->u.initResponse->implementationVersion = + odr_prepend(m_odr, + VERSION, apdu->u.initResponse->implementationVersion); + return apdu; } diff --git a/src/util.hpp b/src/util.hpp index b97df87..6742ebe 100644 --- a/src/util.hpp +++ b/src/util.hpp @@ -109,6 +109,7 @@ namespace metaproxy_1 { int mediumSetPresentNumber, int result_set_size, int &number_to_present); + }; class odr : public boost::noncopyable {