From f9a76666c9aca03278ec20988c1c23b90bc4f451 Mon Sep 17 00:00:00 2001 From: feng lv Date: Sun, 4 Jul 2021 06:31:41 +0000 Subject: [PATCH] fix fix fix fix --- .../FileLog/FileLogDirectoryWatcher.cpp | 49 +++++++++---------- .../FileLog/FileLogDirectoryWatcher.h | 21 ++++---- src/Storages/FileLog/StorageFileLog.cpp | 28 +++++------ ...StorageSystemBuildOptions.generated.cpp.in | 1 - 4 files changed, 48 insertions(+), 51 deletions(-) diff --git a/src/Storages/FileLog/FileLogDirectoryWatcher.cpp b/src/Storages/FileLog/FileLogDirectoryWatcher.cpp index e95f7c55c4d..931f9c9aa06 100644 --- a/src/Storages/FileLog/FileLogDirectoryWatcher.cpp +++ b/src/Storages/FileLog/FileLogDirectoryWatcher.cpp @@ -34,56 +34,55 @@ void FileLogDirectoryWatcher::onItemAdded(const Poco::DirectoryWatcher::Director { std::lock_guard lock(mutex); DirEvent de; - de.callback = "onItemAdded"; - de.path = ev.item.path(); - de.type = ev.event; - events.push_back(de); + de.callback = "onItemAdded"; + de.path = ev.item.path(); + de.type = ev.event; + events.emplace_back(de); } void FileLogDirectoryWatcher::onItemRemoved(const Poco::DirectoryWatcher::DirectoryEvent& ev) { std::lock_guard lock(mutex); - DirEvent de; - de.callback = "onItemRemoved"; - de.path = ev.item.path(); - de.type = ev.event; - events.push_back(de); + DirEvent de; + de.callback = "onItemRemoved"; + de.path = ev.item.path(); + de.type = ev.event; + events.emplace_back(de); } void FileLogDirectoryWatcher::onItemModified(const Poco::DirectoryWatcher::DirectoryEvent& ev) { std::lock_guard lock(mutex); - DirEvent de; - de.callback = "onItemModified"; - de.path = ev.item.path(); - de.type = ev.event; - events.push_back(de); + DirEvent de; + de.callback = "onItemModified"; + de.path = ev.item.path(); + de.type = ev.event; + events.emplace_back(de); } void FileLogDirectoryWatcher::onItemMovedFrom(const Poco::DirectoryWatcher::DirectoryEvent& ev) { std::lock_guard lock(mutex); DirEvent de; - de.callback = "onItemMovedFrom"; - de.path = ev.item.path(); - de.type = ev.event; - events.push_back(de); + de.callback = "onItemMovedFrom"; + de.path = ev.item.path(); + de.type = ev.event; + events.emplace_back(de); } void FileLogDirectoryWatcher::onItemMovedTo(const Poco::DirectoryWatcher::DirectoryEvent& ev) { std::lock_guard lock(mutex); - DirEvent de; - de.callback = "onItemMovedTo"; - de.path = ev.item.path(); - de.type = ev.event; - events.push_back(de); + DirEvent de; + de.callback = "onItemMovedTo"; + de.path = ev.item.path(); + de.type = ev.event; + events.emplace_back(de); } - void FileLogDirectoryWatcher::onError(const Poco::Exception &) { - error = true; + error = true; } diff --git a/src/Storages/FileLog/FileLogDirectoryWatcher.h b/src/Storages/FileLog/FileLogDirectoryWatcher.h index b0fde72f57c..de15186a3b8 100644 --- a/src/Storages/FileLog/FileLogDirectoryWatcher.h +++ b/src/Storages/FileLog/FileLogDirectoryWatcher.h @@ -4,20 +4,19 @@ #include #include -#include #include class FileLogDirectoryWatcher { public: struct DirEvent - { - Poco::DirectoryWatcher::DirectoryEventType type; - std::string callback; - std::string path; - }; + { + Poco::DirectoryWatcher::DirectoryEventType type; + std::string callback; + std::string path; + }; - using Events = std::deque; + using Events = std::vector; explicit FileLogDirectoryWatcher(const std::string & path_); ~FileLogDirectoryWatcher() = default; @@ -30,10 +29,10 @@ public: protected: void onItemAdded(const Poco::DirectoryWatcher::DirectoryEvent& ev); - void onItemRemoved(const Poco::DirectoryWatcher::DirectoryEvent& ev); - void onItemModified(const Poco::DirectoryWatcher::DirectoryEvent& ev); - void onItemMovedFrom(const Poco::DirectoryWatcher::DirectoryEvent& ev); - void onItemMovedTo(const Poco::DirectoryWatcher::DirectoryEvent& ev); + void onItemRemoved(const Poco::DirectoryWatcher::DirectoryEvent & ev); + void onItemModified(const Poco::DirectoryWatcher::DirectoryEvent& ev); + void onItemMovedFrom(const Poco::DirectoryWatcher::DirectoryEvent & ev); + void onItemMovedTo(const Poco::DirectoryWatcher::DirectoryEvent & ev); void onError(const Poco::Exception &); private: diff --git a/src/Storages/FileLog/StorageFileLog.cpp b/src/Storages/FileLog/StorageFileLog.cpp index f6f1535c97e..a5e1b8731da 100644 --- a/src/Storages/FileLog/StorageFileLog.cpp +++ b/src/Storages/FileLog/StorageFileLog.cpp @@ -88,28 +88,28 @@ Pipe StorageFileLog::read( void StorageFileLog::startup() { - try - { - createReadBuffer(); - } - catch (const Exception &) - { - tryLogCurrentException(log); - } + try + { + createReadBuffer(); + } + catch (const Exception &) + { + tryLogCurrentException(log); + } - task->holder->activateAndSchedule(); + task->holder->activateAndSchedule(); } void StorageFileLog::shutdown() { - task->stream_cancelled = true; + task->stream_cancelled = true; - LOG_TRACE(log, "Waiting for cleanup"); - task->holder->deactivate(); + LOG_TRACE(log, "Waiting for cleanup"); + task->holder->deactivate(); - LOG_TRACE(log, "Closing files"); - destroyReadBuffer(); + LOG_TRACE(log, "Closing files"); + destroyReadBuffer(); } size_t StorageFileLog::getMaxBlockSize() const diff --git a/src/Storages/System/StorageSystemBuildOptions.generated.cpp.in b/src/Storages/System/StorageSystemBuildOptions.generated.cpp.in index 18cab0700ec..bb25342bd87 100644 --- a/src/Storages/System/StorageSystemBuildOptions.generated.cpp.in +++ b/src/Storages/System/StorageSystemBuildOptions.generated.cpp.in @@ -50,7 +50,6 @@ const char * auto_config_build[] "USE_LDAP", "@USE_LDAP@", "TZDATA_VERSION", "@TZDATA_VERSION@", "USE_KRB5", "@USE_KRB5@", - "USE_KRB5", "@USE_KRB5@", "USE_FILELOG", "@USE_FILELOG@", nullptr, nullptr