XRootD
Loading...
Searching...
No Matches
XrdCl::ForkHandler Class Reference

#include <XrdClForkHandler.hh>

+ Collaboration diagram for XrdCl::ForkHandler:

Public Member Functions

 ForkHandler ()
 
void Child ()
 Handler the child post-fork.
 
void Parent ()
 Handle the parent post-fork.
 
void Prepare ()
 Handle the preparation part of the forking process.
 
void RegisterFileObject (FileStateHandler *file)
 Register a file object.
 
void RegisterFileSystemObject (FileSystem *fs)
 
void RegisterFileTimer (FileTimer *fileTimer)
 
void RegisterPostMaster (PostMaster *postMaster)
 Register a post master object.
 
void UnRegisterFileObject (FileStateHandler *file)
 
void UnRegisterFileSystemObject (FileSystem *fs)
 Un-register a file system object.
 

Detailed Description

Definition at line 35 of file XrdClForkHandler.hh.

Constructor & Destructor Documentation

◆ ForkHandler()

XrdCl::ForkHandler::ForkHandler ( )

Definition at line 32 of file XrdClForkHandler.cc.

32 :
33 pPostMaster(0), pFileTimer(0)
34 {
35 }

Member Function Documentation

◆ Child()

void XrdCl::ForkHandler::Child ( )

Handler the child post-fork.

Definition at line 102 of file XrdClForkHandler.cc.

103 {
104 Log *log = DefaultEnv::GetLog();
105 pid_t pid = getpid();
106 log->Debug( UtilityMsg, "Running the child fork handler for process %d",
107 pid );
108
109 log->Debug( UtilityMsg, "Unlocking File and FileSystem objects for "
110 "process: %d", pid );
111
112 std::set<FileStateHandler*>::iterator itFile;
113 for( itFile = pFileObjects.begin(); itFile != pFileObjects.end();
114 ++itFile )
115 {
116 (*itFile)->AfterForkChild();
117 (*itFile)->UnLock();
118 }
119
120 std::set<FileSystem*>::iterator itFs;
121 for( itFs = pFileSystemObjects.begin(); itFs != pFileSystemObjects.end();
122 ++itFs )
123 (*itFs)->UnLock();
124
125 pFileTimer->UnLock();
126 if( pPostMaster )
127 {
128 pPostMaster->Finalize();
129 pPostMaster->Initialize();
130 pPostMaster->Start();
131 pPostMaster->GetTaskManager()->RegisterTask( pFileTimer, time(0), false );
132 }
133
134 pMutex.UnLock();
135 }
static Log * GetLog()
Get default log.
const uint64_t UtilityMsg
XrdSysError Log
Definition XrdConfig.cc:113

References XrdCl::Log::Debug(), XrdCl::DefaultEnv::GetLog(), and XrdCl::UtilityMsg.

Referenced by child().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ Parent()

void XrdCl::ForkHandler::Parent ( )

Handle the parent post-fork.

Definition at line 72 of file XrdClForkHandler.cc.

73 {
74 Log *log = DefaultEnv::GetLog();
75 pid_t pid = getpid();
76 log->Debug( UtilityMsg, "Running the parent fork handler for process %d",
77 pid );
78
79 log->Debug( UtilityMsg, "Unlocking File and FileSystem objects for "
80 "process: %d", pid );
81
82 std::set<FileStateHandler*>::iterator itFile;
83 for( itFile = pFileObjects.begin(); itFile != pFileObjects.end();
84 ++itFile )
85 (*itFile)->UnLock();
86
87 std::set<FileSystem*>::iterator itFs;
88 for( itFs = pFileSystemObjects.begin(); itFs != pFileSystemObjects.end();
89 ++itFs )
90 (*itFs)->UnLock();
91
92 pFileTimer->UnLock();
93 if( pPostMaster )
94 pPostMaster->Start();
95
96 pMutex.UnLock();
97 }

References XrdCl::Log::Debug(), XrdCl::DefaultEnv::GetLog(), and XrdCl::UtilityMsg.

Referenced by parent().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ Prepare()

void XrdCl::ForkHandler::Prepare ( )

Handle the preparation part of the forking process.

Definition at line 40 of file XrdClForkHandler.cc.

41 {
42 Log *log = DefaultEnv::GetLog();
43 pid_t pid = getpid();
44 log->Debug( UtilityMsg, "Running the prepare fork handler for process %d",
45 pid );
46
47 pMutex.Lock();
48 if( pPostMaster )
49 pPostMaster->Stop();
50 pFileTimer->Lock();
51
52 //--------------------------------------------------------------------------
53 // Lock the user-level objects
54 //--------------------------------------------------------------------------
55 log->Debug( UtilityMsg, "Locking File and FileSystem objects for process: "
56 "%d", pid );
57
58 std::set<FileStateHandler*>::iterator itFile;
59 for( itFile = pFileObjects.begin(); itFile != pFileObjects.end();
60 ++itFile )
61 (*itFile)->Lock();
62
63 std::set<FileSystem*>::iterator itFs;
64 for( itFs = pFileSystemObjects.begin(); itFs != pFileSystemObjects.end();
65 ++itFs )
66 (*itFs)->Lock();
67 }

References XrdCl::Log::Debug(), XrdCl::DefaultEnv::GetLog(), and XrdCl::UtilityMsg.

Referenced by prepare().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ RegisterFileObject()

void XrdCl::ForkHandler::RegisterFileObject ( FileStateHandler * file)
inline

Register a file object.

Definition at line 43 of file XrdClForkHandler.hh.

44 {
45 XrdSysMutexHelper scopedLock( pMutex );
46 pFileObjects.insert( file );
47 }

Referenced by XrdCl::FileStateHandler::FileStateHandler(), and XrdCl::FileStateHandler::FileStateHandler().

+ Here is the caller graph for this function:

◆ RegisterFileSystemObject()

void XrdCl::ForkHandler::RegisterFileSystemObject ( FileSystem * fs)
inline

Definition at line 61 of file XrdClForkHandler.hh.

62 {
63 XrdSysMutexHelper scopedLock( pMutex );
64 pFileSystemObjects.insert( fs );
65 }

◆ RegisterFileTimer()

void XrdCl::ForkHandler::RegisterFileTimer ( FileTimer * fileTimer)
inline

Definition at line 85 of file XrdClForkHandler.hh.

86 {
87 XrdSysMutexHelper scopedLock( pMutex );
88 pFileTimer = fileTimer;
89 }

◆ RegisterPostMaster()

void XrdCl::ForkHandler::RegisterPostMaster ( PostMaster * postMaster)
inline

Register a post master object.

Definition at line 79 of file XrdClForkHandler.hh.

80 {
81 XrdSysMutexHelper scopedLock( pMutex );
82 pPostMaster = postMaster;
83 }

◆ UnRegisterFileObject()

void XrdCl::ForkHandler::UnRegisterFileObject ( FileStateHandler * file)
inline

Definition at line 52 of file XrdClForkHandler.hh.

53 {
54 XrdSysMutexHelper scopedLock( pMutex );
55 pFileObjects.erase( file );
56 }

Referenced by XrdCl::FileStateHandler::~FileStateHandler().

+ Here is the caller graph for this function:

◆ UnRegisterFileSystemObject()

void XrdCl::ForkHandler::UnRegisterFileSystemObject ( FileSystem * fs)
inline

Un-register a file system object.

Definition at line 70 of file XrdClForkHandler.hh.

71 {
72 XrdSysMutexHelper scopedLock( pMutex );
73 pFileSystemObjects.erase( fs );
74 }

Referenced by XrdCl::FileSystem::~FileSystem().

+ Here is the caller graph for this function:

The documentation for this class was generated from the following files: