diff --git a/src/libraries/JANA/JEventSource.h b/src/libraries/JANA/JEventSource.h index 778a4a335..3b63a03d5 100644 --- a/src/libraries/JANA/JEventSource.h +++ b/src/libraries/JANA/JEventSource.h @@ -246,13 +246,13 @@ class JEventSource : public jana::omni::JComponent, public jana::omni::JHasOutpu event->GetJCallGraphRecorder()->SetInsertDataOrigin( previous_origin ); if (result == Result::Success) { + m_event_count += 1; // We end up here if we read an entry in our file or retrieved a message from our socket, // and believe we could obtain another one immediately if we wanted to for (auto* output : m_outputs) { output->InsertCollection(*event); } - m_event_count += 1; - if (m_event_count < first_evt_nr) { + if (m_event_count <= first_evt_nr) { // We immediately throw away this whole event because of nskip // (although really we should be handling this with Seek()) return Result::FailureTryAgain; diff --git a/src/programs/unit_tests/NEventNSkipTests.cc b/src/programs/unit_tests/NEventNSkipTests.cc index 160c4e19f..23d773eca 100644 --- a/src/programs/unit_tests/NEventNSkipTests.cc +++ b/src/programs/unit_tests/NEventNSkipTests.cc @@ -15,12 +15,17 @@ struct NEventNSkipBoundedSource : public JEventSource { std::atomic_int open_count{0}; std::atomic_int close_count{0}; - void GetEvent(std::shared_ptr) override { + NEventNSkipBoundedSource() { + SetCallbackStyle(CallbackStyle::ExpertMode); + } + + Result Emit(JEvent&) override { if (event_count >= event_bound) { - throw JEventSource::RETURN_STATUS::kNO_MORE_EVENTS; + return Result::FailureFinished; } event_count += 1; events_emitted.push_back(event_count); + return Result::Success; } void Open() override {