Grid Community Toolkit  6.2.1705709074 (tag: v6.2.20240202)
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
globus_i_gfork.h
1 #include "globus_common.h"
2 #include "globus_xio.h"
5 #include "globus_gfork.h"
6 
7 #define GFORK_CROWDED_MESSAGE "421 Too busy!\r\n"
8 
9 
10 #if !defined(GFORK_I_H)
11 #define GFORK_I_H 1
12 
13 #ifdef __GNUC__
14 #define GForkFuncName(func) static const char * _gfork_func_name __attribute__((__unused__)) = #func
15 #else
16 #define GForkFuncName(func) static const char * _gfork_func_name = #func
17 #endif
18 
19 #define GForkErrorErrno(_msg, _errno) \
20  globus_error_put(GForkErrorObjErrno(_msg, _errno))
21 
22 #define GForkErrorObjErrno(_msg, _errno) \
23  globus_error_wrap_errno_error( \
24  GLOBUS_GFORK_CHILD_MODULE, \
25  (_errno), \
26  GLOBUS_GFORK_ERROR_ERRNO, \
27  __FILE__, \
28  _gfork_func_name, \
29  __LINE__, \
30  "System error in %s", \
31  _msg)
32 
33 #define GForkErrorStr(_msg) \
34  globus_error_put(GForkErrorObjStr(_msg))
35 
36 #define GForkErrorObjStr(str) \
37  globus_error_construct_error( \
38  GLOBUS_GFORK_CHILD_MODULE, \
39  NULL, \
40  GLOBUS_GFORK_ERROR_STR, \
41  __FILE__, \
42  _gfork_func_name, \
43  __LINE__, \
44  "GFork error: %s", \
45  (str))
46 
47 GlobusDebugDeclare(GLOBUS_GFORK);
48 
49 #define GlobusGForkDebugPrintf(level, message) \
50  GlobusDebugPrintf(GLOBUS_GFORK, level, message)
51 
52 #define GlobusGForkDebugEnter() \
53  GlobusGForkDebugPrintf( \
54  GLOBUS_GFORK_DEBUG_TRACE, \
55  ("[%s] Entering\n", _xio_name))
56 
57 #define GlobusGForkDebugExit() \
58  GlobusGForkDebugPrintf( \
59  GLOBUS_GFORK_DEBUG_TRACE, \
60  ("[%s] Exiting\n", _xio_name))
61 
62 #define GlobusGForkDebugExitWithError() \
63  GlobusGForkDebugPrintf( \
64  GLOBUS_GFORK_DEBUG_TRACE, \
65  ("[%s] Exiting with error\n", _xio_name))
66 
67 #define GlobusGForkDebugState(_old, _new, _event) \
68  GlobusGForkDebugPrintf( \
69  GLOBUS_GFORK_DEBUG_STATE, \
70  ("State Change from %s to %s when %s\n", _old, _new, _event))
71 
72 enum
73 {
74  GLOBUS_GFORK_ERROR_ERRNO = 1,
75  GLOBUS_GFORK_ERROR_STR
76 };
77 
78 typedef enum gfork_i_msg_type_e
79 {
80  GLOBUS_GFORK_MSG_OPEN = 'O',
81  GLOBUS_GFORK_MSG_CLOSE = 'C',
82  GLOBUS_GFORK_MSG_DATA = 'D'
83 } gfork_i_msg_type_t;
84 
85 typedef struct gfork_i_msg_header_s
86 {
87  uint64_t size;
88  pid_t from_pid;
89  pid_t to_pid;
90  gfork_i_msg_type_t type;
91 } gfork_i_msg_header_t;
92 
93 typedef struct gfork_i_msg_data_s
94 {
95  int ref;
96  globus_byte_t buffer[1];
97 } gfork_i_msg_data_t;
98 
99 typedef struct gfork_i_msg_s
100 {
101  gfork_i_msg_header_t header;
102  struct gfork_i_child_handle_s * to_kid;
103  struct gfork_i_child_handle_s * from_kid;
104  void * user_arg;
105  globus_xio_iovec_t * iov;
106  int iovc;
107  globus_size_t nbytes;
108  globus_xio_iovec_t write_iov[2];
109  globus_xio_iovec_callback_t client_cb;
111  gfork_i_msg_data_t * data;
112  globus_byte_t * buffer;
113  struct gfork_i_lib_handle_s * lib_handle;
114 } gfork_i_msg_t;
115 
116 typedef enum gfork_i_state_e
117 {
118  GFORK_STATE_NONE = 0,
119  GFORK_STATE_OPEN,
120  GFORK_STATE_OPENING,
121  GFORK_STATE_OPENING_AND_CLOSING,
122  GFORK_STATE_CLOSING,
123  GFORK_STATE_CLOSED,
124  GFORK_STATE_COUNT
125 } gfork_i_state_t;
126 
127 typedef enum gfork_i_events_s
128 {
129  GFORK_EVENT_NONE = 0,
130  GFORK_EVENT_ACCEPT_CB,
131  GFORK_EVENT_OPEN_RETURNS,
132  GFORK_EVENT_SIGCHILD,
133  GFORK_EVENT_CLOSE_RETURNS,
134  GFORK_EVENT_COUNT
135 } gfork_i_events_t;
136 
137 typedef struct gfork_i_options_s
138 {
139  char * id;
140  globus_list_t * protocol_list;
141  char * server;
142  globus_list_t * server_arg_list;
143  int port;
144  int instances;
145  int nice;
146  char * interfajce;
147  globus_list_t * env_list;
148  uid_t master_user;
149  char * master;
150  int master_nice;
151  globus_list_t * master_arg_list;
152  void * user_arg;
153  globus_bool_t quiet;
154  char * conf_file;
155  int log_level;
156  FILE * log_fptr;
157 
158  char * crowded_msg;
159  int crowded_msg_len;
160 
161  globus_list_t * master_list;
162 } gfork_i_options_t;
163 
164 typedef struct gfork_i_handle_s
165 {
166  globus_xio_stack_t stack;
167  char ** server_argv;
168  char ** master_argv;
169  globus_list_t * loaded_drivers;
170  globus_xio_driver_t tcp_driver;
171  globus_xio_server_t server_xio;
172  gfork_i_options_t * opts;
173 
174  globus_list_t * master_list;
175 } gfork_i_handle_t;
176 
177 typedef struct gfork_i_child_handle_s
178 {
179  pid_t pid;
180  int write_fd;
181  int read_fd;
182  globus_xio_handle_t write_xio_handle;
183  globus_xio_handle_t read_xio_handle;
184  gfork_i_handle_t * whos_my_daddy;
185  void * user_arg;
186  gfork_i_state_t state;
187  globus_bool_t dead;
188  globus_fifo_t write_q;
189  globus_bool_t writting;
190  globus_bool_t master;
191 } gfork_i_child_handle_t;
192 
193 typedef struct gfork_i_lib_handle_s
194 {
195  globus_xio_handle_t read_xio;
196  globus_xio_handle_t write_xio;
197  gfork_i_msg_header_t header;
198  globus_byte_t * data;
199  globus_gfork_incoming_cb_t incoming_cb;
200  globus_gfork_open_func_t open_cb;
201  globus_gfork_closed_func_t close_cb;
202  globus_gfork_error_func_t error_cb;
203  globus_bool_t master;
204  void * user_arg;
205  globus_mutex_t mutex;
206  gfork_i_state_t state;
207  globus_fifo_t write_q;
208  globus_bool_t writing;
209  globus_object_t * error_obj;
210 } gfork_i_lib_handle_t;
211 
212 typedef struct gfork_i_master_program_ent_s
213 {
214  char * master;
215  uid_t master_uid;
216  int master_nice;
217  globus_list_t * master_arg_list;
218  globus_list_t * master_env;
219 } gfork_i_master_program_ent_t;
220 
222 gfork_i_make_xio_handle(
223  globus_xio_handle_t * xio_handle,
224  int fd);
225 
226 void
227 gfork_i_state_init();
228 
229 gfork_i_state_t
230 gfork_i_state_next(
231  gfork_i_state_t current_state,
232  gfork_i_events_t event);
233 
235 globus_i_opts_to_handle(
236  gfork_i_options_t * opts,
237  gfork_i_handle_t * handle);
238 
239 extern globus_xio_stack_t gfork_i_file_stack;
240 extern globus_xio_attr_t gfork_i_file_attr;
241 extern globus_xio_driver_t gfork_i_file_driver;
242 
243 extern globus_options_entry_t gfork_l_opts_table[];
244 
245 #endif
int globus_bool_t
Boolean type.
Definition: globus_types.h:93
struct globus_fifo_s * globus_fifo_t
Definition: globus_fifo.h:48
List data type.
Definition: globus_list.h:44
Header file for XIO TCP Driver.
XIO File Driver.
Mutex.
Definition: globus_thread.h:107
size_t globus_size_t
Standard size of memory objectThe globus_size_t is the size of a memory object. It is identical to si...
Definition: globus_types.h:48
unsigned char globus_byte_t
Unsigned byte datatypeThis is used for byte-addressable arrays of arbitrary data which is not subject...
Definition: globus_types.h:85
Headers common to all of Globus.
uint32_t globus_result_t
Definition: globus_types.h:99
void(* globus_xio_iovec_callback_t)(globus_xio_handle_t handle, globus_result_t result, globus_xio_iovec_t *iovec, int count, globus_size_t nbytes, globus_xio_data_descriptor_t data_desc, void *user_arg)
Definition: globus_xio.h:619