xrootd
XrdClForkHandler.hh
Go to the documentation of this file.
1 //------------------------------------------------------------------------------
2 // Copyright (c) 2012 by European Organization for Nuclear Research (CERN)
3 // Author: Lukasz Janyst <ljanyst@cern.ch>
4 //------------------------------------------------------------------------------
5 // XRootD is free software: you can redistribute it and/or modify
6 // it under the terms of the GNU Lesser General Public License as published by
7 // the Free Software Foundation, either version 3 of the License, or
8 // (at your option) any later version.
9 //
10 // XRootD is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
14 //
15 // You should have received a copy of the GNU Lesser General Public License
16 // along with XRootD. If not, see <http://www.gnu.org/licenses/>.
17 //------------------------------------------------------------------------------
18 
19 #ifndef __XRD_CL_FORK_HANDLER_HH__
20 #define __XRD_CL_FORK_HANDLER_HH__
21 
22 #include <XrdSys/XrdSysPthread.hh>
23 #include <set>
24 
25 namespace XrdCl
26 {
27  class FileStateHandler;
28  class FileSystem;
29  class PostMaster;
30  class FileTimer;
31 
32  //----------------------------------------------------------------------------
33  // Helper class for handling forking
34  //----------------------------------------------------------------------------
36  {
37  public:
38  ForkHandler();
39 
40  //------------------------------------------------------------------------
42  //------------------------------------------------------------------------
44  {
45  XrdSysMutexHelper scopedLock( pMutex );
46  pFileObjects.insert( file );
47  }
48 
49  //------------------------------------------------------------------------
50  // Un-register a file object
51  //------------------------------------------------------------------------
53  {
54  XrdSysMutexHelper scopedLock( pMutex );
55  pFileObjects.erase( file );
56  }
57 
58  //------------------------------------------------------------------------
59  // Register a file system object
60  //------------------------------------------------------------------------
62  {
63  XrdSysMutexHelper scopedLock( pMutex );
64  pFileSystemObjects.insert( fs );
65  }
66 
67  //------------------------------------------------------------------------
69  //------------------------------------------------------------------------
71  {
72  XrdSysMutexHelper scopedLock( pMutex );
73  pFileSystemObjects.erase( fs );
74  }
75 
76  //------------------------------------------------------------------------
78  //------------------------------------------------------------------------
79  void RegisterPostMaster( PostMaster *postMaster )
80  {
81  XrdSysMutexHelper scopedLock( pMutex );
82  pPostMaster = postMaster;
83  }
84 
85  void RegisterFileTimer( FileTimer *fileTimer )
86  {
87  XrdSysMutexHelper scopedLock( pMutex );
88  pFileTimer = fileTimer;
89  }
90 
91  //------------------------------------------------------------------------
93  //------------------------------------------------------------------------
94  void Prepare();
95 
96  //------------------------------------------------------------------------
98  //------------------------------------------------------------------------
99  void Parent();
100 
101  //------------------------------------------------------------------------
103  //------------------------------------------------------------------------
104  void Child();
105 
106  private:
107  std::set<FileStateHandler*> pFileObjects;
108  std::set<FileSystem*> pFileSystemObjects;
112  };
113 }
114 
115 #endif // __XRD_CL_FORK_HANDLER_HH__
Definition: XrdClForkHandler.hh:35
void RegisterFileSystemObject(FileSystem *fs)
Definition: XrdClForkHandler.hh:61
void RegisterPostMaster(PostMaster *postMaster)
Register a post master object.
Definition: XrdClForkHandler.hh:79
std::set< FileSystem * > pFileSystemObjects
Definition: XrdClForkHandler.hh:108
void RegisterFileObject(FileStateHandler *file)
Register a file object.
Definition: XrdClForkHandler.hh:43
void UnRegisterFileObject(FileStateHandler *file)
Definition: XrdClForkHandler.hh:52
void Child()
Handler the child post-fork.
void Parent()
Handle the parent post-fork.
Definition: XrdSysPthread.hh:165
XrdSysMutex pMutex
Definition: XrdClForkHandler.hh:111
Definition: XrdClAnyObject.hh:25
void Prepare()
Handle the preparation part of the forking process.
std::set< FileStateHandler * > pFileObjects
Definition: XrdClForkHandler.hh:107
Handle the stateful operations.
Definition: XrdClFileStateHandler.hh:79
Task generating timeout events for FileStateHandlers in recovery mode.
Definition: XrdClFileTimer.hh:32
void RegisterFileTimer(FileTimer *fileTimer)
Definition: XrdClForkHandler.hh:85
void UnRegisterFileSystemObject(FileSystem *fs)
Un-register a file system object.
Definition: XrdClForkHandler.hh:70
Send file/filesystem queries to an XRootD cluster.
Definition: XrdClFileSystem.hh:202
FileTimer * pFileTimer
Definition: XrdClForkHandler.hh:110
A hub for dispatching and receiving messages.
Definition: XrdClPostMaster.hh:47
PostMaster * pPostMaster
Definition: XrdClForkHandler.hh:109
Definition: XrdSysPthread.hh:262