Fixes
This commit is contained in:
@ -248,9 +248,11 @@ namespace IACore
|
||||
SocketOps::Close(session->ListenerSocket);
|
||||
session->ListenerSocket = INVALID_SOCKET;
|
||||
|
||||
const auto sessionID = session->ProcessHandle->ID.load();
|
||||
const auto sessionPtr = session.get();
|
||||
m_activeSessions.push_back(std::move(session));
|
||||
m_pendingSessions.erase(m_pendingSessions.begin() + i);
|
||||
m_activeSessionMap[session->ProcessHandle->ID.load()] = session.get();
|
||||
m_activeSessionMap[sessionID] = sessionPtr;
|
||||
}
|
||||
}
|
||||
|
||||
@ -280,7 +282,7 @@ namespace IACore
|
||||
SocketOps::Close(node->DataSocket);
|
||||
|
||||
m_activeSessions.erase(m_activeSessions.begin() + i);
|
||||
m_activeSessionMap.erase(node->ProcessHandle->ID.load());
|
||||
m_activeSessionMap.erase(nodeID);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -364,15 +366,41 @@ namespace IACore
|
||||
UNUSED(result);
|
||||
});
|
||||
|
||||
// Give some time for child node to stablize
|
||||
std::this_thread::sleep_for(std::chrono::seconds(1));
|
||||
if (!session->ProcessHandle->IsActive())
|
||||
return MakeUnexpected(std::format("Failed to spawn the child process \"{}\"", executablePath.string()));
|
||||
|
||||
auto processID = session->ProcessHandle->ID.load();
|
||||
|
||||
session->CreationTime = SteadyClock::now();
|
||||
m_pendingSessions.push_back(std::move(session));
|
||||
|
||||
return session->ProcessHandle->ID.load();
|
||||
return processID;
|
||||
}
|
||||
|
||||
VOID IPC_Manager::ShutdownNode(IN NativeProcessID pid)
|
||||
BOOL IPC_Manager::WaitTillNodeIsOnline(IN NativeProcessID nodeID)
|
||||
{
|
||||
const auto itNode = m_activeSessionMap.find(pid);
|
||||
BOOL isPending = true;
|
||||
while (isPending)
|
||||
{
|
||||
isPending = false;
|
||||
for (auto it = m_pendingSessions.begin(); it != m_pendingSessions.end(); it++)
|
||||
{
|
||||
if (it->get()->ProcessHandle->ID.load() == nodeID)
|
||||
{
|
||||
isPending = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
Update();
|
||||
}
|
||||
return m_activeSessionMap.contains(nodeID);
|
||||
}
|
||||
|
||||
VOID IPC_Manager::ShutdownNode(IN NativeProcessID nodeID)
|
||||
{
|
||||
const auto itNode = m_activeSessionMap.find(nodeID);
|
||||
if (itNode == m_activeSessionMap.end())
|
||||
return;
|
||||
|
||||
|
||||
@ -52,6 +52,13 @@ namespace IACore
|
||||
s_logLevel = logLevel;
|
||||
}
|
||||
|
||||
VOID Logger::FlushLogs()
|
||||
{
|
||||
std::cout.flush();
|
||||
if (s_logFile)
|
||||
s_logFile.flush();
|
||||
}
|
||||
|
||||
VOID Logger::LogInternal(IN PCCHAR prefix, IN PCCHAR tag, IN String &&msg)
|
||||
{
|
||||
const auto outLine = std::format("[{:>8.3f}]: [{}]: {}", GetSecondsCount(), tag, msg);
|
||||
|
||||
@ -70,7 +70,7 @@ namespace IACore
|
||||
class IPC_Node
|
||||
{
|
||||
public:
|
||||
~IPC_Node();
|
||||
virtual ~IPC_Node();
|
||||
|
||||
// When Manager spawns a node, `connectionString` is passed
|
||||
// as the first command line argument
|
||||
@ -121,14 +121,15 @@ namespace IACore
|
||||
|
||||
public:
|
||||
IPC_Manager();
|
||||
~IPC_Manager();
|
||||
virtual ~IPC_Manager();
|
||||
|
||||
VOID Update();
|
||||
|
||||
Expected<NativeProcessID, String> SpawnNode(IN CONST FilePath &executablePath,
|
||||
IN UINT32 sharedMemorySize = DEFAULT_NODE_SHARED_MEMORY_SIZE);
|
||||
BOOL WaitTillNodeIsOnline(IN NativeProcessID node);
|
||||
|
||||
VOID ShutdownNode(IN NativeProcessID pid);
|
||||
VOID ShutdownNode(IN NativeProcessID node);
|
||||
|
||||
VOID SendSignal(IN NativeProcessID node, IN UINT8 signal);
|
||||
VOID SendPacket(IN NativeProcessID node, IN UINT16 packetID, IN Span<CONST UINT8> payload);
|
||||
|
||||
@ -55,8 +55,30 @@ namespace IACore
|
||||
LogError(std::vformat(fmt.get(), std::make_format_args(args...)));
|
||||
}
|
||||
|
||||
STATIC VOID FlushLogs();
|
||||
|
||||
private:
|
||||
#if IA_ENABLE_LOGGING > 0
|
||||
#if IA_DISABLE_LOGGING > 0
|
||||
STATIC VOID LogStatus(IN String &&msg)
|
||||
{
|
||||
UNUSED(msg);
|
||||
}
|
||||
|
||||
STATIC VOID LogInfo(IN String &&msg)
|
||||
{
|
||||
UNUSED(msg);
|
||||
}
|
||||
|
||||
STATIC VOID LogWarn(IN String &&msg)
|
||||
{
|
||||
UNUSED(msg);
|
||||
}
|
||||
|
||||
STATIC VOID LogError(IN String &&msg)
|
||||
{
|
||||
UNUSED(msg);
|
||||
}
|
||||
#else
|
||||
STATIC VOID LogStatus(IN String &&msg)
|
||||
{
|
||||
if (s_logLevel <= ELogLevel::VERBOSE)
|
||||
@ -80,26 +102,6 @@ namespace IACore
|
||||
if (s_logLevel <= ELogLevel::ERROR)
|
||||
LogInternal(__CC_RED, "ERROR", IA_MOVE(msg));
|
||||
}
|
||||
#else
|
||||
STATIC VOID LogStatus(IN String &&msg)
|
||||
{
|
||||
UNUSED(msg);
|
||||
}
|
||||
|
||||
STATIC VOID LogInfo(IN String &&msg)
|
||||
{
|
||||
UNUSED(msg);
|
||||
}
|
||||
|
||||
STATIC VOID LogWarn(IN String &&msg)
|
||||
{
|
||||
UNUSED(msg);
|
||||
}
|
||||
|
||||
STATIC VOID LogError(IN String &&msg)
|
||||
{
|
||||
UNUSED(msg);
|
||||
}
|
||||
#endif
|
||||
|
||||
STATIC VOID LogInternal(IN PCCHAR prefix, IN PCCHAR tag, IN String &&msg);
|
||||
@ -114,4 +116,4 @@ namespace IACore
|
||||
friend VOID Initialize();
|
||||
friend VOID Terminate();
|
||||
};
|
||||
}
|
||||
} // namespace IACore
|
||||
Reference in New Issue
Block a user