From 269f1f750fb44258d04ef74230b92bc86401e7b2 Mon Sep 17 00:00:00 2001 From: Greg Eisenhauer Date: Thu, 7 Mar 2024 15:10:55 -0500 Subject: [PATCH] Raise an exception if remote open fails (#4069) Raise an exception if remote open fails --- source/adios2/engine/bp5/BP5Reader.cpp | 45 +++++++++++++++++++------- source/adios2/engine/bp5/BP5Reader.h | 1 + thirdparty/EVPath/EVPath/cmsockets.c | 1 - 3 files changed, 35 insertions(+), 12 deletions(-) diff --git a/source/adios2/engine/bp5/BP5Reader.cpp b/source/adios2/engine/bp5/BP5Reader.cpp index a2854b2de2..e8fba5f3f3 100644 --- a/source/adios2/engine/bp5/BP5Reader.cpp +++ b/source/adios2/engine/bp5/BP5Reader.cpp @@ -272,6 +272,36 @@ std::pair BP5Reader::ReadData(adios2::transportman::TransportMan void BP5Reader::PerformGets() { + // if dataIsRemote is true and m_Remote is not true, this is our first time through + // PerformGets() Either we don't need a remote open (m_dataIsRemote=false), or we need to Open + // remote file (or die trying) + if (m_dataIsRemote && !m_Remote) + { + bool RowMajorOrdering = (m_IO.m_ArrayOrder == ArrayOrdering::RowMajor); + + // If nothing is pending, don't open + if (m_BP5Deserializer->PendingGetRequests.size() == 0) + return; + + if (!m_Parameters.RemoteDataPath.empty()) + { + m_Remote.Open("localhost", RemoteCommon::ServerPort, m_Parameters.RemoteDataPath, + m_OpenMode, RowMajorOrdering); + } + else if (getenv("DoRemote")) + { + m_Remote.Open("localhost", RemoteCommon::ServerPort, m_Name, m_OpenMode, + RowMajorOrdering); + } + if (!m_Remote) + { + helper::Throw( + "Engine", "BP5Reader", "OpenFiles", + "Remote file " + m_Name + + " cannot be opened. Possible server or file specification error."); + } + } + if (m_Remote) { PerformRemoteGets(); @@ -477,18 +507,11 @@ void BP5Reader::Init() OpenFiles(timeoutInstant, pollSeconds, timeoutSeconds); UpdateBuffer(timeoutInstant, pollSeconds / 10, timeoutSeconds); - // This isn't how we'll trigger remote ops in the end, but a temporary - // solution - bool RowMajorOrdering = (m_IO.m_ArrayOrder == ArrayOrdering::RowMajor); + // Don't try to open the remote file when we open local metadata. Do that on demand. if (!m_Parameters.RemoteDataPath.empty()) - { - m_Remote.Open("localhost", RemoteCommon::ServerPort, m_Parameters.RemoteDataPath, - m_OpenMode, RowMajorOrdering); - } - else if (getenv("DoRemote")) - { - m_Remote.Open("localhost", RemoteCommon::ServerPort, m_Name, m_OpenMode, RowMajorOrdering); - } + m_dataIsRemote = true; + if (getenv("DoRemote")) + m_dataIsRemote = true; } void BP5Reader::InitParameters() diff --git a/source/adios2/engine/bp5/BP5Reader.h b/source/adios2/engine/bp5/BP5Reader.h index 440158e509..5e121cfa2d 100644 --- a/source/adios2/engine/bp5/BP5Reader.h +++ b/source/adios2/engine/bp5/BP5Reader.h @@ -92,6 +92,7 @@ class BP5Reader : public BP5Engine, public Engine /* transport manager for managing the active flag file */ transportman::TransportMan m_ActiveFlagFileManager; + bool m_dataIsRemote = false; Remote m_Remote; bool m_WriterIsActive = true; adios2::profiling::JSONProfiler m_JSONProfiler; diff --git a/thirdparty/EVPath/EVPath/cmsockets.c b/thirdparty/EVPath/EVPath/cmsockets.c index 5a70aded91..a054fd452d 100644 --- a/thirdparty/EVPath/EVPath/cmsockets.c +++ b/thirdparty/EVPath/EVPath/cmsockets.c @@ -457,7 +457,6 @@ initiate_conn(CManager cm, CMtrans_services svc, transport_entry trans, attr_lis int err = WSAGetLastError(); if (err != WSAEWOULDBLOCK || err != WSAEINPROGRESS) { #endif - printf("Errno was %d\n", errno); svc->trace_out(cm, "CMSocket connect FAILURE --> Connect() to IP %s failed", ip_str); close(sock); #ifdef WSAEWOULDBLOCK