//
// Copyright (c) 2017-2025, Manticore Software LTD (https://manticoresearch.com)
// Copyright (c) 2001-2016, Andrew Aksyonoff
// Copyright (c) 2008-2016, Sphinx Technologies Inc
// All rights reserved
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License. You should have
// received a copy of the GPL license along with this program; if you
// did not, you can find it at http://www.gnu.org
//

#pragma once

#include "sphinxstd.h"

int StopDaemonAndWait ( bool bWait, int iPid, int iWaitTimeout );
CSphString GetNamedPipeName ( int iPid );

// result of the reload auth command \ unifying exit codes.
enum class ReloadAuthResult_e : int
{
	SUCCESS      = 0, ///< operation successful
	CLIENT_ERROR = 1, ///< client-side error (pipe creation \ timeout waiting for daemon)
	DAEMON_ERROR = 2, ///< daemon received the command but reported error during execution
	IPC_ERROR    = 3  ///< IPC communication error occurred (poll \ read failed)
};

// auth reload command and signal check
ReloadAuthResult_e CommandReloadAuthAndWaitReply ( int iPid, int iWaitTimeout, CSphString & sError );
bool AuthReloadSignalled ( int iPid );
void ManageIpcSession();

constexpr BYTE PIPE_CMD_CHECK_CMD = 2;
void ProcessAuthReloadPipe ( int iPid );
