Windows: use Boost 1.59, msvc 14.0
[metaproxy-moved-to-github.git] / src / filter_log.cpp
index b46815c..27ebadb 100644 (file)
@@ -72,11 +72,6 @@ namespace metaproxy_1 {
             bool m_init_options;
             LFilePtr m_file;
             std::string m_time_format;
-            // Only used during confiqgure stage (no threading),
-            // for performance avoid opening files which other log filter
-            // instances already have opened
-            static std::list<LFilePtr> filter_log_files;
-
             boost::mutex m_session_mutex;
             std::map<mp::Session, std::string> m_sessions;
        };
@@ -93,7 +88,7 @@ namespace metaproxy_1 {
                      std::ostringstream &os);
             void flush();
         };
-
+        static std::list<yf::Log::Impl::LFilePtr> filter_log_files;
     }
 }
 
@@ -123,10 +118,6 @@ void yf::Log::process(mp::Package &package) const
 }
 
 
-// static initialization
-std::list<yf::Log::Impl::LFilePtr> yf::Log::Impl::filter_log_files;
-
-
 yf::Log::Impl::Impl(const std::string &x)
     : m_msg_config(x),
       m_1line(false),
@@ -335,7 +326,6 @@ static void log_1line_Z_APDU(Z_APDU *z_req, Z_APDU *z_res, WRBUF w)
                     res->records->u.multipleNonSurDiagnostics->diagRecs);
             }
             wrbuf_puts(w, " ");
-            assert(req->preferredRecordSyntax);
             log_syntax(w, req->preferredRecordSyntax);
 
             wrbuf_printf(w, " %s " ODR_INT_PRINTF "+" ODR_INT_PRINTF " ",
@@ -691,7 +681,11 @@ void yf::Log::Impl::process(mp::Package &package)
             {
                 mp::odr odr(ODR_PRINT);
                 odr_set_stream(odr, m_file->fhandle, stream_write, 0);
+                if (!m_file->fhandle)
+                    yaz_log_lock();
                 z_GDU(odr, &gdu_req, 0, 0);
+                if (!m_file->fhandle)
+                    yaz_log_unlock();
             }
         }
     }
@@ -701,6 +695,8 @@ void yf::Log::Impl::process(mp::Package &package)
 
     Z_GDU *gdu_res = package.response().get();
 
+    gdu_req = package.request().get();
+
     yaz_timing_stop(timer);
     double duration = yaz_timing_get_real(timer);
 
@@ -784,7 +780,11 @@ void yf::Log::Impl::process(mp::Package &package)
             {
                 mp::odr odr(ODR_PRINT);
                 odr_set_stream(odr, m_file->fhandle, stream_write, 0);
+                if (!m_file->fhandle)
+                    yaz_log_lock();
                 z_GDU(odr, &gdu_res, 0, 0);
+                if (!m_file->fhandle)
+                    yaz_log_unlock();
             }
         }
     }