irods  4.2.8
About: iRODS (the integrated Rule Oriented Data System) is a distributed data-management system for creating data grids, digital libraries, persistent archives, and real-time data systems.
  Fossies Dox: irods-4.2.8.tar.gz  ("unofficial" and yet experimental doxygen-generated source code documentation)  

rodsServer.cpp File Reference
#include "rcMisc.h"
#include "rodsServer.hpp"
#include "sharedmemory.hpp"
#include "initServer.hpp"
#include "miscServerFunct.hpp"
#include <syslog.h>
#include <pthread.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include "irods_exception.hpp"
#include "irods_server_state.hpp"
#include "irods_client_server_negotiation.hpp"
#include "irods_network_factory.hpp"
#include "irods_re_plugin.hpp"
#include "irods_server_properties.hpp"
#include "irods_server_control_plane.hpp"
#include "procLog.h"
#include "rsGlobalExtern.hpp"
#include "locks.hpp"
#include <boost/filesystem.hpp>
#include <boost/filesystem/operations.hpp>
#include <boost/filesystem/convenience.hpp>
#include <boost/range/iterator_range.hpp>
#include "sockCommNetworkInterface.hpp"
#include "sys/un.h"
#include "irods_random.hpp"
#include <boost/thread/thread.hpp>
#include <boost/thread/mutex.hpp>
#include <boost/thread/condition.hpp>
Include dependency graph for rodsServer.cpp:

Go to the source code of this file.

Classes

struct  local_addr
 

Functions

std::vector< std::string > setExecArg (const char *commandArgv)
 
int runIrodsAgentFactory (sockaddr_un agent_addr)
 
int queueConnectedAgentProc (int childPid, agentProc_t *connReq, agentProc_t **agentProcHead)
 
static void set_agent_spawner_process_name (const InformationRequiredToSafelyRenameProcess &info)
 
int main (int argc, char **argv)
 
int serverize (char *logDir)
 
static bool instantiate_shared_memory_for_plugin (const std::unordered_map< std::string, boost::any > &_plugin_object)
 
static bool uninstantiate_shared_memory_for_plugin (const std::unordered_map< std::string, boost::any > &_plugin_object)
 
static irods::error instantiate_shared_memory ()
 
static irods::error uninstantiate_shared_memory ()
 
int serverMain (char *logDir)
 
void serverExit ()
 
void usage (char *prog)
 
int procChildren (agentProc_t **agentProcHead)
 
agentProc_tgetAgentProcByPid (int childPid, agentProc_t **agentProcHead)
 
int spawnAgent (agentProc_t *connReq, agentProc_t **agentProcHead)
 
int sendEnvironmentVarIntToSocket (const char *var, int val, int socket)
 
int sendEnvironmentVarStrToSocket (const char *var, const char *val, int socket)
 
ssize_t sendSocketOverSocket (int writeFd, int socket)
 
int execAgent (int newSock, startupPack_t *startupPack)
 
int getAgentProcCnt ()
 
int getAgentProcPIDs (std::vector< int > &_pids)
 
int chkAgentProcCnt ()
 
int chkConnectedAgentProcQue ()
 
int initServer (rsComm_t *svrComm)
 
int recordServerProcess (rsComm_t *svrComm)
 
int initServerMain (rsComm_t *svrComm)
 
int addConnReqToQue (rsComm_t *rsComm, int sock)
 
int initConnThreadEnv ()
 
agentProc_tgetConnReqFromQue ()
 
int startProcConnReqThreads ()
 
void stopProcConnReqThreads ()
 
void readWorkerTask ()
 
void spawnManagerTask ()
 
int procSingleConnReq (agentProc_t *connReq)
 
int procBadReq ()
 
void purgeLockFileWorkerTask ()
 

Variables

int agent_conn_socket {}
 
bool connected_to_agent {}
 
pid_t agent_spawning_pid {}
 
const char socket_dir_template [] {"/tmp/irods_sockets_XXXXXX"}
 
char agent_factory_socket_dir [sizeof(socket_dir_template)] {}
 
char agent_factory_socket_file [sizeof(local_addr.sun_path)] {}
 
uint ServerBootTime
 
int SvrSock
 
agentProc_tConnectedAgentHead = 0
 
agentProc_tConnReqHead = 0
 
agentProc_tSpawnReqHead = 0
 
agentProc_tBadReqHead = 0
 
boost::mutex ConnectedAgentMutex
 
boost::mutex BadReqMutex
 
boost::thread * ReadWorkerThread [5]
 
boost::thread * SpawnManagerThread
 
boost::thread * PurgeLockFileThread
 
boost::mutex ReadReqCondMutex
 
boost::mutex SpawnReqCondMutex
 
boost::condition_variable ReadReqCond
 
boost::condition_variable SpawnReqCond
 

Function Documentation

◆ addConnReqToQue()

int addConnReqToQue ( rsComm_t rsComm,
int  sock 
)

Definition at line 1288 of file rodsServer.cpp.

References BOTTOM_POS, ConnReqHead, queAgentProc(), ReadReqCond, ReadReqCondMutex, rsComm_t::remoteAddr, agentProc::remoteAddr, and agentProc::sock.

Referenced by serverMain().

Here is the call graph for this function:

◆ chkAgentProcCnt()

int chkAgentProcCnt ( )

Definition at line 1021 of file rodsServer.cpp.

References chkConnectedAgentProcQue(), terminate_irods_processes::e, getAgentProcCnt(), KEY_NOT_FOUND, irods::log(), NO_MAX_CONNECTION_LIMIT, and SYS_MAX_CONNECT_COUNT_EXCEEDED.

Referenced by serverMain().

Here is the call graph for this function:

◆ chkConnectedAgentProcQue()

int chkConnectedAgentProcQue ( )

Definition at line 1047 of file rodsServer.cpp.

References ConnectedAgentHead, ConnectedAgentMutex, irods::experimental::administration::client::v1::exists(), LOG_DEBUG, MAX_NAME_LEN, agentProc::next, NULL, pid_age::p, agentProc::pid, ProcLogDir, and rodsLog().

Referenced by chkAgentProcCnt().

Here is the call graph for this function:

◆ execAgent()

◆ getAgentProcByPid()

agentProc_t* getAgentProcByPid ( int  childPid,
agentProc_t **  agentProcHead 
)

Definition at line 695 of file rodsServer.cpp.

References ConnectedAgentMutex, agentProc::next, NULL, and agentProc::pid.

◆ getAgentProcCnt()

int getAgentProcCnt ( )

◆ getAgentProcPIDs()

int getAgentProcPIDs ( std::vector< int > &  _pids)

◆ getConnReqFromQue()

agentProc_t* getConnReqFromQue ( )

Definition at line 1310 of file rodsServer.cpp.

References ConnReqHead, irods::server_state::EXITED, irods::server_state::instance(), agentProc::next, NULL, ReadReqCond, ReadReqCondMutex, and irods::server_state::STOPPED.

Referenced by readWorkerTask().

Here is the call graph for this function:

◆ initConnThreadEnv()

int initConnThreadEnv ( )

Definition at line 1305 of file rodsServer.cpp.

Referenced by startProcConnReqThreads().

◆ initServer()

◆ initServerMain()

◆ instantiate_shared_memory()

static irods::error instantiate_shared_memory ( )
static

Definition at line 376 of file rodsServer.cpp.

References irods::CFG_PLUGIN_CONFIGURATION_KW(), terminate_irods_processes::e, ERROR, error, irods::get_server_property(), instantiate_shared_memory_for_plugin(), INVALID_ANY_CAST, irods::PLUGIN_TYPE_RULE_ENGINE(), and SUCCESS.

Referenced by serverMain().

Here is the call graph for this function:

◆ instantiate_shared_memory_for_plugin()

static bool instantiate_shared_memory_for_plugin ( const std::unordered_map< std::string, boost::any > &  _plugin_object)
static

Definition at line 354 of file rodsServer.cpp.

References irods::CFG_SHARED_MEMORY_INSTANCE_KW(), detachSharedMemory(), and prepareServerSharedMemory().

Referenced by instantiate_shared_memory().

Here is the call graph for this function:

◆ main()

◆ procBadReq()

int procBadReq ( )

Definition at line 1599 of file rodsServer.cpp.

References BadReqHead, BadReqMutex, agentProc::next, and NULL.

Referenced by spawnManagerTask().

◆ procChildren()

int procChildren ( agentProc_t **  agentProcHead)

Definition at line 663 of file rodsServer.cpp.

References ConnectedAgentMutex, agentProc::next, NULL, and agentProc::pid.

Referenced by serverMain().

◆ procSingleConnReq()

◆ purgeLockFileWorkerTask()

void purgeLockFileWorkerTask ( )

Definition at line 1620 of file rodsServer.cpp.

References irods::server_state::EXITED, irods::server_state::instance(), LOCK_FILE_PURGE_TIME, LOG_ERROR, purgeLockFileDir(), rodsLogError(), rodsSleep(), irods::SERVER_CONTROL_POLLING_TIME_MILLI_SEC, irods.pypyodbc::status, and irods::server_state::STOPPED.

Referenced by serverMain().

Here is the call graph for this function:

◆ queueConnectedAgentProc()

int queueConnectedAgentProc ( int  childPid,
agentProc_t connReq,
agentProc_t **  agentProcHead 
)

Definition at line 967 of file rodsServer.cpp.

References ConnectedAgentMutex, NULL, agentProc::pid, queAgentProc(), TOP_POS, and USER__NULL_INPUT_ERR.

Referenced by spawnAgent().

Here is the call graph for this function:

◆ readWorkerTask()

◆ recordServerProcess()

int recordServerProcess ( rsComm_t svrComm)

Definition at line 1140 of file rodsServer.cpp.

References LOG_ERROR, rsComm_t::myEnv, myPid, NULL, rodsLog(), and rodsEnv::rodsPort.

Referenced by initServerMain(), and serverExit().

Here is the call graph for this function:

◆ runIrodsAgentFactory()

int runIrodsAgentFactory ( sockaddr_un  agent_addr)

Definition at line 188 of file rodsAgent.cpp.

References agentMain(), rsComm_t::auth_scheme, irods::environment_properties::capture(), irods::server_properties::capture(), irods::CFG_SERVICE_ROLE_PROVIDER(), chkAllowedUser(), chkLogfileName(), chlDebug(), cleanup(), cleanupAndExit(), irods::client_server_negotiation_for_server(), rsComm_t::clientUser, irods::error::code(), rsComm_t::cookie, irods::CS_NEG_FAILURE(), get_catalog_service_role(), irods::get_client_api_table(), irods::get_pack_table(), irods::get_server_api_table(), getLogfileName(), getRodsEnv(), irods::init_api_table(), initAgent(), initProcLog(), initRsCommWithStartupPack(), irods::environment_properties::instance(), irods::server_properties::instance(), irodsAgentSignalExit(), irods::log(), LOG_DEBUG, LOG_ERROR, LOG_NOTICE, logAgentProc(), LogFd, rsComm_t::myEnv, rsComm_t::negotiation_results, irods::network_factory(), NULL, irods::error::ok(), PASS, irods::re_plugin_globals, receiveDataFromServer(), rsComm_t::reconnAddr, rsComm_t::reconnPort, register_handlers(), irods::error::result(), rmProcLog(), RODS_LOGFILE, rodsEnv::rodsDebug, rodsLog(), userInfo_t::rodsZone, RsApiTable, RULE_ENGINE_TRY_CACHE, sendVersion(), SERVER_NEGOTIATION_ERROR, setRECacheSaltFromEnv(), sockAgentStart, sockAgentStop, irods.pypyodbc::status, SYS_AGENT_INIT_ERR, SYS_FORK_ERROR, SYS_INTERNAL_ERR, SYS_SOCK_ACCEPT_ERR, SYS_SOCK_BIND_ERR, SYS_SOCK_LISTEN_ERR, SYS_SOCK_OPEN_ERR, SYS_SOCK_READ_ERR, SYS_SOCK_SELECT_ERR, rsComm_t::thread_ctx, and userInfo_t::userName.

Referenced by main().

Here is the call graph for this function:

◆ sendEnvironmentVarIntToSocket()

int sendEnvironmentVarIntToSocket ( const char *  var,
int  val,
int  socket 
)

Definition at line 743 of file rodsServer.cpp.

References LOG_DEBUG, LOG_ERROR, rodsLog(), and irods.pypyodbc::status.

Referenced by execAgent().

Here is the call graph for this function:

◆ sendEnvironmentVarStrToSocket()

int sendEnvironmentVarStrToSocket ( const char *  var,
const char *  val,
int  socket 
)

Definition at line 756 of file rodsServer.cpp.

References LOG_DEBUG, LOG_ERROR, rodsLog(), and irods.pypyodbc::status.

Referenced by execAgent().

Here is the call graph for this function:

◆ sendSocketOverSocket()

ssize_t sendSocketOverSocket ( int  writeFd,
int  socket 
)

Definition at line 769 of file rodsServer.cpp.

References terminate_irods_processes::control, and NULL.

Referenced by execAgent().

◆ serverExit()

void serverExit ( )

Definition at line 633 of file rodsServer.cpp.

References agent_conn_socket, agent_factory_socket_dir, agent_factory_socket_file, agent_spawning_pid, LOG_NOTICE, NULL, recordServerProcess(), and rodsLog().

Referenced by main().

Here is the call graph for this function:

◆ serverize()

int serverize ( char *  logDir)

Definition at line 308 of file rodsServer.cpp.

References getLogfileName(), LOG_NOTICE, LogFd, NULL, RODS_SERVER_LOGFILE, and rodsLog().

Referenced by main().

Here is the call graph for this function:

◆ serverMain()

◆ set_agent_spawner_process_name()

static void set_agent_spawner_process_name ( const InformationRequiredToSafelyRenameProcess info)
static

◆ setExecArg()

std::vector< std::string > setExecArg ( const char *  commandArgv)

Definition at line 1647 of file rodsServer.cpp.

References NULL.

◆ spawnAgent()

int spawnAgent ( agentProc_t connReq,
agentProc_t **  agentProcHead 
)

Definition at line 723 of file rodsServer.cpp.

References execAgent(), NULL, queueConnectedAgentProc(), agentProc::sock, agentProc::startupPack, and USER__NULL_INPUT_ERR.

Referenced by procSingleConnReq(), and spawnManagerTask().

Here is the call graph for this function:

◆ spawnManagerTask()

◆ startProcConnReqThreads()

int startProcConnReqThreads ( )

Definition at line 1342 of file rodsServer.cpp.

References initConnThreadEnv(), LOG_ERROR, NUM_READ_WORKER_THR, readWorkerTask(), ReadWorkerThread, rodsLog(), spawnManagerTask(), SpawnManagerThread, and SYS_THREAD_RESOURCE_ERR.

Referenced by serverMain().

Here is the call graph for this function:

◆ stopProcConnReqThreads()

void stopProcConnReqThreads ( )

Definition at line 1365 of file rodsServer.cpp.

References LOG_ERROR, NUM_READ_WORKER_THR, ReadReqCond, ReadWorkerThread, rodsLog(), SpawnManagerThread, and SpawnReqCond.

Referenced by serverMain().

Here is the call graph for this function:

◆ uninstantiate_shared_memory()

static irods::error uninstantiate_shared_memory ( )
static

Definition at line 398 of file rodsServer.cpp.

References irods::CFG_PLUGIN_CONFIGURATION_KW(), terminate_irods_processes::e, ERROR, error, irods::get_server_property(), INVALID_ANY_CAST, irods::PLUGIN_TYPE_RULE_ENGINE(), SUCCESS, and uninstantiate_shared_memory_for_plugin().

Referenced by serverMain().

Here is the call graph for this function:

◆ uninstantiate_shared_memory_for_plugin()

static bool uninstantiate_shared_memory_for_plugin ( const std::unordered_map< std::string, boost::any > &  _plugin_object)
static

Definition at line 365 of file rodsServer.cpp.

References irods::CFG_SHARED_MEMORY_INSTANCE_KW(), removeSharedMemory(), and resetMutex().

Referenced by uninstantiate_shared_memory().

Here is the call graph for this function:

◆ usage()

void usage ( char *  prog)

Definition at line 653 of file rodsServer.cpp.

Referenced by main().

Variable Documentation

◆ agent_conn_socket

int agent_conn_socket {}

Definition at line 46 of file rodsServer.cpp.

Referenced by execAgent(), main(), serverExit(), and serverMain().

◆ agent_factory_socket_dir

char agent_factory_socket_dir[sizeof(socket_dir_template)] {}

Definition at line 51 of file rodsServer.cpp.

Referenced by execAgent(), main(), serverExit(), and serverMain().

◆ agent_factory_socket_file

char agent_factory_socket_file[sizeof(local_addr.sun_path)] {}

Definition at line 52 of file rodsServer.cpp.

Referenced by main(), serverExit(), and serverMain().

◆ agent_spawning_pid

pid_t agent_spawning_pid {}

Definition at line 49 of file rodsServer.cpp.

Referenced by main(), serverExit(), and serverMain().

◆ BadReqHead

agentProc_t* BadReqHead = 0

Definition at line 60 of file rodsServer.cpp.

Referenced by procBadReq(), and readWorkerTask().

◆ BadReqMutex

boost::mutex BadReqMutex

Definition at line 66 of file rodsServer.cpp.

Referenced by procBadReq(), and readWorkerTask().

◆ connected_to_agent

bool connected_to_agent {}

Definition at line 47 of file rodsServer.cpp.

◆ ConnectedAgentHead

◆ ConnectedAgentMutex

boost::mutex ConnectedAgentMutex

◆ ConnReqHead

agentProc_t* ConnReqHead = 0

Definition at line 58 of file rodsServer.cpp.

Referenced by addConnReqToQue(), and getConnReqFromQue().

◆ PurgeLockFileThread

boost::thread* PurgeLockFileThread

Definition at line 70 of file rodsServer.cpp.

Referenced by serverMain().

◆ ReadReqCond

boost::condition_variable ReadReqCond

Definition at line 74 of file rodsServer.cpp.

Referenced by addConnReqToQue(), getConnReqFromQue(), and stopProcConnReqThreads().

◆ ReadReqCondMutex

boost::mutex ReadReqCondMutex

Definition at line 72 of file rodsServer.cpp.

Referenced by addConnReqToQue(), and getConnReqFromQue().

◆ ReadWorkerThread

boost::thread* ReadWorkerThread[5]

Definition at line 67 of file rodsServer.cpp.

Referenced by startProcConnReqThreads(), and stopProcConnReqThreads().

◆ ServerBootTime

uint ServerBootTime

Definition at line 54 of file rodsServer.cpp.

Referenced by execAgent(), and main().

◆ socket_dir_template

const char socket_dir_template[] {"/tmp/irods_sockets_XXXXXX"}

Definition at line 50 of file rodsServer.cpp.

Referenced by main().

◆ SpawnManagerThread

boost::thread* SpawnManagerThread

Definition at line 68 of file rodsServer.cpp.

Referenced by startProcConnReqThreads(), and stopProcConnReqThreads().

◆ SpawnReqCond

boost::condition_variable SpawnReqCond

Definition at line 75 of file rodsServer.cpp.

Referenced by readWorkerTask(), spawnManagerTask(), and stopProcConnReqThreads().

◆ SpawnReqCondMutex

boost::mutex SpawnReqCondMutex

Definition at line 73 of file rodsServer.cpp.

Referenced by readWorkerTask(), and spawnManagerTask().

◆ SpawnReqHead

agentProc_t* SpawnReqHead = 0

Definition at line 59 of file rodsServer.cpp.

Referenced by readWorkerTask(), and spawnManagerTask().

◆ SvrSock

int SvrSock

Definition at line 55 of file rodsServer.cpp.

Referenced by serverMain().