Fix GCC warnings. Set imp name/version for init response
authorAdam Dickmeiss <adam@indexdata.dk>
Thu, 11 Jun 2009 11:51:06 +0000 (13:51 +0200)
committerAdam Dickmeiss <adam@indexdata.dk>
Thu, 11 Jun 2009 11:51:06 +0000 (13:51 +0200)
12 files changed:
src/ex_filter_frontend_net.cpp
src/filter_backend_test.cpp
src/metaproxy_prog.cpp
src/sru_util.cpp
src/test_filter_auth_simple.cpp
src/test_filter_frontend_net.cpp
src/test_filter_log.cpp
src/test_filter_multi.cpp
src/test_session2.cpp
src/thread_pool_observer.cpp
src/util.cpp
src/util.hpp

index f9a4ef4..c5e4da6 100644 (file)
@@ -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;
index 7881e57..2ad6424 100644 (file)
@@ -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;
index 47f84ab..4cba424 100644 (file)
@@ -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;
index 45e5823..7a96b8d 100644 (file)
@@ -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}
          };
 
 
index f939858..e057842 100644 (file)
@@ -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();
index 16cbe4e..df80938 100644 (file)
@@ -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();
index a14b827..db02fb7 100644 (file)
@@ -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();
index 710bafd..d441d4a 100644 (file)
@@ -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();
index 13c4890..394e3c9 100644 (file)
@@ -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)
index 64ddc62..e473c1a 100644 (file)
@@ -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
         }
     }
index 6482063..7676d06 100644 (file)
@@ -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;
 }
 
index b97df87..6742ebe 100644 (file)
@@ -109,6 +109,7 @@ namespace metaproxy_1 {
                        int mediumSetPresentNumber,
                        int result_set_size,
                        int &number_to_present);
+
     };
 
     class odr : public boost::noncopyable {