Skip to content

Commit

Permalink
dds-session to skip bad sid
Browse files Browse the repository at this point in the history
dds-session: Fixed: skip bad or non-session directories/files when performing clean and list operations.
  • Loading branch information
AnarManafov committed Mar 7, 2022
1 parent c80898c commit 8332a2d
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 2 deletions.
2 changes: 1 addition & 1 deletion BuildSetup.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ set( CMAKE_BUILD_TYPE Release CACHE STRING "Choose the type of build" FORCE )
# This is needed to be able to build DDS worker packages.
# Otherwise cmake look up algorithms can't find boost libs on wn_bin build
#
set(Boost_NO_BOOST_CMAKE TRUE CACHE BOOL "" FORCE)
#set(Boost_NO_BOOST_CMAKE TRUE CACHE BOOL "" FORCE)


#
Expand Down
3 changes: 3 additions & 0 deletions ReleaseNotes.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
### DDS common
Added: every DDS module logs now its pid, group id and parent pid. (GH-403)

### dds-session
Fixed: skip bad or non-session directories/files when performing clean and list operations.

### dds-submit
Added: Users can specify a GroupName tag for each submission. This tag will be assigned to agents and can be used as a requirement in topologies. (GH-407)

Expand Down
27 changes: 26 additions & 1 deletion dds-session/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,25 @@ using namespace dds::session_cmd;
using namespace dds::user_defaults_api;
namespace fs = boost::filesystem;

bool IsValid(const string& _sid)
{
try
{
boost::uuids::uuid sid{ boost::uuids::string_generator()(_sid) };
if (sid.is_nil())
return false;
}
catch (...)
{
return false;
}

return true;
}

bool IsSessionRunning(const string& _sid)
{
CUserDefaults::instance().reinit(boost::uuids::string_generator()(_sid), CUserDefaults::instance().currentUDFile());

return CUserDefaults::instance().IsSessionRunning();
}

Expand Down Expand Up @@ -81,6 +96,9 @@ void listSessions(const vector<fs::path>& _session_dirs, SSessionsSorting::EType
for (auto& dir : sortedDirs)
{
string sSID = dir.second.leaf().string();
if (!IsValid(sSID))
continue;

time_t tmLastUseTime = fs::last_write_time(dir.second);
char sLastUseTime[1000];
struct tm* p = localtime(&tmLastUseTime);
Expand Down Expand Up @@ -174,6 +192,9 @@ int main(int argc, char* argv[])
rebuildSessions(session_dirs, sessions);
for (const auto& i : sessions)
{
if (!IsValid(i))
continue;

if (!IsSessionRunning(i))
continue;

Expand Down Expand Up @@ -212,6 +233,10 @@ int main(int argc, char* argv[])
{
const string sSID(dir.leaf().string());

// Ignore non-sid or bad items
if (!IsValid(sSID))
continue;

if (IsSessionRunning(sSID))
continue;

Expand Down

0 comments on commit 8332a2d

Please sign in to comment.