Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[12529] Fix file watch initialization #2280

Merged
merged 7 commits into from
Nov 11, 2021
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions src/cpp/rtps/RTPSDomain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,10 @@
#include <fastdds/rtps/RTPSDomain.h>

#include <chrono>
#include <thread>
#include <cstdlib>
#include <regex>
#include <string>
#include <thread>

#include <fastdds/dds/log/Log.hpp>
#include <fastdds/rtps/history/WriterHistory.h>
Expand Down Expand Up @@ -115,11 +116,15 @@ RTPSParticipant* RTPSDomain::createParticipant(
// Only the first time, initialize environment file watch if the corresponding environment variable is set
if (!RTPSDomainImpl::file_watch_handle_)
{
if (!SystemInfo::get_environment_file().empty())
std::string filename = SystemInfo::get_environment_file();
if (!filename.empty() && SystemInfo::file_exists(filename))
{
// Create filewatch
RTPSDomainImpl::file_watch_handle_ = SystemInfo::watch_file(SystemInfo::get_environment_file(),
RTPSDomainImpl::file_watch_callback);
RTPSDomainImpl::file_watch_handle_ = SystemInfo::watch_file(filename, RTPSDomainImpl::file_watch_callback);
}
else
{
logWarning(RTPS_PARTICIPANT, filename + " does not exist. File watching not initialized.");
}
}

Expand Down
Loading