fix

fix

fix
This commit is contained in:
feng lv 2021-07-04 06:31:41 +00:00
parent 4be47ca7e7
commit f9a76666c9
4 changed files with 48 additions and 51 deletions

View File

@ -34,56 +34,55 @@ void FileLogDirectoryWatcher::onItemAdded(const Poco::DirectoryWatcher::Director
{
std::lock_guard<std::mutex> 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<std::mutex> 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<std::mutex> 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<std::mutex> 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<std::mutex> 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;
}

View File

@ -4,20 +4,19 @@
#include <Poco/Foundation.h>
#include <Poco/Path.h>
#include <deque>
#include <mutex>
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<DirEvent>;
using Events = std::vector<DirEvent>;
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:

View File

@ -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

View File

@ -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