diff --git a/aminclude_static.am b/aminclude_static.am index e0c3f382..85475a5d 100644 --- a/aminclude_static.am +++ b/aminclude_static.am @@ -1,6 +1,6 @@ # aminclude_static.am generated automatically by Autoconf -# from AX_AM_MACROS_STATIC on Sat Jun 4 10:09:23 PDT 2022 +# from AX_AM_MACROS_STATIC on Sat Jun 4 14:05:13 PDT 2022 # Code coverage diff --git a/configure.ac b/configure.ac index cadf37e6..9e3cb696 100644 --- a/configure.ac +++ b/configure.ac @@ -102,7 +102,7 @@ AC_SEARCH_LIBS(BZ2_bzopen, bz2, AC_SUBST(BZIP2_SUPPORT) AC_SEARCH_LIBS(dlopen, dl) AC_SEARCH_LIBS(backtrace, execinfo) -LIBCURL_CHECK_CONFIG([], [7.23.0], [], [AC_MSG_ERROR([libz required to build])], [test x"${enable_static}" = x"yes"]) +LIBCURL_CHECK_CONFIG([], [7.23.0], [], [AC_MSG_ERROR([libcurl required to build])], [test x"${enable_static}" = x"yes"]) # Sometimes, curses depends on these libraries being linked in... AC_ARG_ENABLE([tinfo], diff --git a/m4/libcurl.m4 b/m4/libcurl.m4 index a13775c2..d2768d92 100644 --- a/m4/libcurl.m4 +++ b/m4/libcurl.m4 @@ -128,7 +128,14 @@ AC_DEFUN([LIBCURL_CHECK_CONFIG], fi if test x"$LIBCURL" = "x" ; then if $5; then - LIBCURL=`$_libcurl_config --static-libs` + case "$host_os" in + darwin*) + LIBCURL=`$_libcurl_config --libs` + ;; + *) + LIBCURL=`$_libcurl_config --static-libs` + ;; + esac else LIBCURL=`$_libcurl_config --libs` fi @@ -143,6 +150,23 @@ AC_DEFUN([LIBCURL_CHECK_CONFIG], esac fi + dnl If we are on OS X and we haven't picked up libcurl static or + dnl otherwise, then let's just go ahead and use the one present on + dnl the system. Since this compiled binary will only run on OS X + dnl which almost always has cURL installed, it's OK to add the + dnl static dependency. + AS_IF([test "x${LIBCURL}" = "x"], + [AS_CASE(["$host_os"], + [darwin*], + [AS_IF([test "x$_libcurl_config" != "x"], + AS_VAR_SET(LIBCURL, $($_libcurl_config --libs)), + [] + )], + [] + )], + [] + ) + # All curl-config scripts support --feature _libcurl_features=`$_libcurl_config --feature` diff --git a/src/log_format_impls.cc b/src/log_format_impls.cc index 42a38631..21e1ab46 100644 --- a/src/log_format_impls.cc +++ b/src/log_format_impls.cc @@ -236,7 +236,10 @@ class generic_log_format : public log_format { std::shared_ptr specialized(int fmt_lock) override { - return std::make_shared(*this); + auto retval = std::make_shared(*this); + + retval->lf_specialized = true; + return retval; } }; @@ -505,11 +508,15 @@ public: } if (found_ts) { + if (!this->lf_specialized) { + for (auto& ll : dst) { + ll.set_ignore(true); + } + } dst.emplace_back(li.li_file_range.fr_offset, tv, level, 0, opid); return SCAN_MATCH; - } else { - return SCAN_NO_MATCH; } + return SCAN_NO_MATCH; } scan_result_t scan(logfile& lf, @@ -728,7 +735,10 @@ public: std::shared_ptr specialized(int fmt_lock = -1) override { - return std::make_shared(*this); + auto retval = std::make_shared(*this); + + retval->lf_specialized = true; + return retval; } class bro_log_table : public log_format_vtab_impl { @@ -1111,11 +1121,16 @@ public: tv.tv_sec = tm2sec(&tm.et_tm); tv.tv_usec = tm.et_nsec / 1000; + if (!this->lf_specialized) { + for (auto& ll : dst) { + ll.set_ignore(true); + } + } dst.emplace_back(li.li_file_range.fr_offset, tv, level, 0); return SCAN_MATCH; - } else { - return SCAN_NO_MATCH; } + + return SCAN_NO_MATCH; } scan_result_t scan(logfile& lf, @@ -1249,7 +1264,6 @@ public: } if (!this->wlf_format_name.empty() && !this->wlf_field_defs.empty()) { - dst.clear(); return this->scan_int(dst, li, sbr); } @@ -1322,7 +1336,10 @@ public: std::shared_ptr specialized(int fmt_lock = -1) override { - return std::make_shared(*this); + auto retval = std::make_shared(*this); + + retval->lf_specialized = true; + return retval; } class w3c_log_table : public log_format_vtab_impl { @@ -1771,7 +1788,10 @@ public: std::shared_ptr specialized(int fmt_lock) override { - return std::make_shared(*this); + auto retval = std::make_shared(*this); + + retval->lf_specialized = true; + return retval; } }; diff --git a/src/logfile.cc b/src/logfile.cc index 980c3f1d..87930875 100644 --- a/src/logfile.cc +++ b/src/logfile.cc @@ -260,6 +260,8 @@ logfile::process_prefix(shared_buffer_ref& sbr, const line_info& li) } } + log_debug("match found %d %d", found, li.li_file_range.fr_offset); + switch (found) { case log_format::SCAN_MATCH: if (!this->lf_index.empty()) { @@ -328,6 +330,8 @@ logfile::process_prefix(shared_buffer_ref& sbr, const line_info& li) break; } + log_debug("index size %d", this->lf_index.size()); + return retval; } diff --git a/test/drive_logfile.cc b/test/drive_logfile.cc index d93e198b..2da37dd8 100644 --- a/test/drive_logfile.cc +++ b/test/drive_logfile.cc @@ -137,9 +137,6 @@ main(int argc, char* argv[]) lf->rebuild_index(); assert(!lf->is_closed()); assert(lf->get_activity().la_polls == 3); - if (lf->size() > 1) { - assert(lf->get_activity().la_reads == 2); - } if (expected_format.empty()) { assert(lf->get_format() == nullptr); } else { diff --git a/test/expected/expected.am b/test/expected/expected.am index 4e0a4189..c30af3f6 100644 --- a/test/expected/expected.am +++ b/test/expected/expected.am @@ -264,6 +264,8 @@ EXPECTED_FILES = \ $(srcdir)/%reldir%/test_logfile.sh_3fc6bfd8a6160817211f3e14fde957af75b9dbe7.out \ $(srcdir)/%reldir%/test_logfile.sh_4a2a907fcb069b8d6e65961a7b2e796d6c3a87b1.err \ $(srcdir)/%reldir%/test_logfile.sh_4a2a907fcb069b8d6e65961a7b2e796d6c3a87b1.out \ + $(srcdir)/%reldir%/test_logfile.sh_7c2e11488bccc59458b5775db4b90de964858259.err \ + $(srcdir)/%reldir%/test_logfile.sh_7c2e11488bccc59458b5775db4b90de964858259.out \ $(srcdir)/%reldir%/test_logfile.sh_a7037efd0c4bbf51940137a44e57d94e9307e83e.err \ $(srcdir)/%reldir%/test_logfile.sh_a7037efd0c4bbf51940137a44e57d94e9307e83e.out \ $(srcdir)/%reldir%/test_logfile.sh_c18e14a26d8261c9f72747118a469266121d5459.err \ diff --git a/test/expected/test_logfile.sh_290a3c49e53c2229a7400c107338fa0bb38375e2.out b/test/expected/test_logfile.sh_290a3c49e53c2229a7400c107338fa0bb38375e2.out index 573541ac..7731fde8 100644 --- a/test/expected/test_logfile.sh_290a3c49e53c2229a7400c107338fa0bb38375e2.out +++ b/test/expected/test_logfile.sh_290a3c49e53c2229a7400c107338fa0bb38375e2.out @@ -1 +1,2 @@ +#Fields: ? ) 0 diff --git a/test/expected/test_logfile.sh_4a2a907fcb069b8d6e65961a7b2e796d6c3a87b1.out b/test/expected/test_logfile.sh_4a2a907fcb069b8d6e65961a7b2e796d6c3a87b1.out index 36b8c5a8..8de34b8a 100644 --- a/test/expected/test_logfile.sh_4a2a907fcb069b8d6e65961a7b2e796d6c3a87b1.out +++ b/test/expected/test_logfile.sh_4a2a907fcb069b8d6e65961a7b2e796d6c3a87b1.out @@ -1,2 +1,4 @@ +#Fields: 0 cs-bytes +#Fields: 0 0 # 0 diff --git a/test/expected/test_logfile.sh_7c2e11488bccc59458b5775db4b90de964858259.err b/test/expected/test_logfile.sh_7c2e11488bccc59458b5775db4b90de964858259.err new file mode 100644 index 00000000..e69de29b diff --git a/test/expected/test_logfile.sh_7c2e11488bccc59458b5775db4b90de964858259.out b/test/expected/test_logfile.sh_7c2e11488bccc59458b5775db4b90de964858259.out new file mode 100644 index 00000000..13576d89 --- /dev/null +++ b/test/expected/test_logfile.sh_7c2e11488bccc59458b5775db4b90de964858259.out @@ -0,0 +1,6 @@ +000 +000 +#Fields: 0 +0 +#Fields: 0 +0 diff --git a/test/test_logfile.sh b/test/test_logfile.sh index a4daf975..dfe96abc 100644 --- a/test/test_logfile.sh +++ b/test/test_logfile.sh @@ -6,6 +6,9 @@ echo ${top_builddir} printf '#Date:\t20\x800-2-02\n0\n' | run_cap_test \ env TEST_COMMENT="short timestamp" ${lnav_test} -n +printf '000\n000\n#Fields: 0\n0\n#Fields: 0\n0' | run_cap_test \ + env TEST_COMMENT="invalid w3c log" ${lnav_test} -n + cat > rollover_in.0 <