Skip to content

Commit

Permalink
Don't allow Container insertion in READ_LINEAR (#1590)
Browse files Browse the repository at this point in the history
Also clear the IO queue after failed flushes
  • Loading branch information
franzpoeschel authored Jan 30, 2024
1 parent 8faadde commit d9fce66
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
5 changes: 3 additions & 2 deletions include/openPMD/backend/Container.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#pragma once

#include "openPMD/Error.hpp"
#include "openPMD/IO/Access.hpp"
#include "openPMD/backend/Attributable.hpp"

#include <initializer_list>
Expand Down Expand Up @@ -289,7 +290,7 @@ class Container : virtual public Attributable
{
if (IOHandler()->m_seriesStatus !=
internal::SeriesStatus::Parsing &&
Access::READ_ONLY == IOHandler()->m_frontendAccess)
access::readOnly(IOHandler()->m_frontendAccess))
{
auxiliary::OutOfRangeMsg const out_of_range_msg;
throw std::out_of_range(out_of_range_msg(key));
Expand Down Expand Up @@ -330,7 +331,7 @@ class Container : virtual public Attributable
{
if (IOHandler()->m_seriesStatus !=
internal::SeriesStatus::Parsing &&
Access::READ_ONLY == IOHandler()->m_frontendAccess)
access::readOnly(IOHandler()->m_frontendAccess))
{
auxiliary::OutOfRangeMsg out_of_range_msg;
throw std::out_of_range(out_of_range_msg(key));
Expand Down
7 changes: 6 additions & 1 deletion src/Series.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -737,7 +737,12 @@ std::future<void> Series::flush_impl(
}
catch (...)
{
IOHandler()->m_lastFlushSuccessful = false;
auto handler = IOHandler();
handler->m_lastFlushSuccessful = false;
while (!handler->m_work.empty())
{
handler->m_work.pop();
}
throw;
}
}
Expand Down

0 comments on commit d9fce66

Please sign in to comment.