diff --git a/src/tailer/tailer.looper.cc b/src/tailer/tailer.looper.cc index 88272fe5..248270aa 100644 --- a/src/tailer/tailer.looper.cc +++ b/src/tailer/tailer.looper.cc @@ -533,8 +533,20 @@ void tailer::looper::host_tailer::loop_body() log_debug("Got an error: %s -- %s", pe.pe_path.c_str(), pe.pe_msg.c_str()); - if (conn.c_desired_paths.count(pe.pe_path)) { + auto desired_iter = conn.c_desired_paths.find(pe.pe_path); + if (desired_iter != conn.c_desired_paths.end()) { report_error(this->get_display_path(pe.pe_path), pe.pe_msg); + if (!desired_iter->second.loo_tail) { + conn.c_desired_paths.erase(desired_iter); + } + } + else { + auto child_iter = conn.c_child_paths.find(pe.pe_path); + + if (child_iter != conn.c_child_paths.end() && + !child_iter->second.loo_tail) { + conn.c_child_paths.erase(child_iter); + } } auto remote_path = ghc::filesystem::absolute( @@ -544,6 +556,14 @@ void tailer::looper::host_tailer::loop_body() log_debug("removing %s", local_path.c_str()); this->ht_active_files.erase(local_path); ghc::filesystem::remove_all(local_path); + + if (conn.c_desired_paths.empty() && + conn.c_child_paths.empty()) { + log_info("tailer(%s): all desired paths synced", + this->ht_netloc.c_str()); + return state_v{synced{}}; + } + return std::move(this->ht_state); }, [&](const tailer::packet_offer_block &pob) { diff --git a/test/Makefile.am b/test/Makefile.am index 5655357e..f691a8b6 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -337,6 +337,8 @@ dist_noinst_DATA = \ log-samples/sample-27353a72ba4025448f261dcfa6ea16e474187795.txt \ log-samples/sample-70c906b3c1a1cf03f15bde92ee78edfa6f9b7960.txt \ log-samples/sample-ad31f12d2adabd07e3ddda3ad5b0dbf6b49c4c99.txt \ + remote-log-dir/logfile_access_log.0 \ + remote-log-dir/logfile_access_log.1 \ tui-captures/tui_echo.0 \ tui-captures/tui_help.0 @@ -426,7 +428,7 @@ DISTCLEANFILES = \ all-local: remote/ssh_host_dsa_key remote/ssh_host_rsa_key remote/id_rsa distclean-local: - $(RM_V)rm -rf remote + $(RM_V)rm -rf remote remote-tmp $(RM_V)rm -rf sessions $(RM_V)rm -rf tmp $(RM_V)rm -rf rotmp diff --git a/test/remote-log-dir/logfile_access_log.0 b/test/remote-log-dir/logfile_access_log.0 new file mode 100644 index 00000000..a90f29fd --- /dev/null +++ b/test/remote-log-dir/logfile_access_log.0 @@ -0,0 +1,3 @@ +192.168.202.254 - - [20/Jul/2009:22:59:26 +0000] "GET /vmw/cgi/tramp HTTP/1.0" 200 134 "-" "gPXE/0.9.7" +192.168.202.254 - - [20/Jul/2009:22:59:29 +0000] "GET /vmw/vSphere/default/vmkboot.gz HTTP/1.0" 404 46210 "-" "gPXE/0.9.7" +192.168.202.254 - - [20/Jul/2009:22:59:29 +0000] "GET /vmw/vSphere/default/vmkernel.gz HTTP/1.0" 200 78929 "-" "gPXE/0.9.7" diff --git a/test/remote-log-dir/logfile_access_log.1 b/test/remote-log-dir/logfile_access_log.1 new file mode 100644 index 00000000..ad2b37e2 --- /dev/null +++ b/test/remote-log-dir/logfile_access_log.1 @@ -0,0 +1 @@ +10.112.81.15 - - [15/Feb/2013:06:00:31 +0000] "-" 400 0 "-" "-" diff --git a/test/test_remote.sh b/test/test_remote.sh index 8d434906..30f6cf9c 100644 --- a/test/test_remote.sh +++ b/test/test_remote.sh @@ -2,6 +2,10 @@ export HOME=${PWD}/remote +rm -rf remote-tmp +mkdir -p remote-tmp +export TMPDIR=remote-tmp + cat > remote/sshd_config <