17 #ifndef GLOBUS_DONT_DOCUMENT_INTERNAL 19 #if !defined(GLOBUS_I_XIO_H) 20 #define GLOBUS_I_XIO_H 1 22 #include "globus_xio.h" 23 #include "globus_xio_driver.h" 25 #include "globus_xio_util.h" 26 #include "globus_xio_load.h" 28 #define GLOBUS_XIO_ATTR_ARRAY_BASE_SIZE 16 29 #define GLOBUS_XIO_HANDLE_DEFAULT_OPERATION_COUNT 4 36 #define GlobusXIOCurrentBlockedThread(blocked_thread) \ 37 if (globus_i_am_only_thread()) \ 39 blocked_thread.thread = globus_thread_self(); \ 43 blocked_thread.depth = globus_callback_space_get_depth( \ 44 GLOBUS_CALLBACK_GLOBAL_SPACE); \ 46 #define GlobusXIOBlockedThreadMatchesCurrentThread(a) \ 47 (globus_i_am_only_thread() \ 49 globus_callback_space_get_depth(GLOBUS_CALLBACK_GLOBAL_SPACE)) \ 50 : globus_thread_equal(a.thread, globus_thread_self())) 52 GlobusDebugDeclare(GLOBUS_XIO);
54 #define GlobusXIODebugPrintf(level, message) \ 55 GlobusDebugPrintf(GLOBUS_XIO, level, message) 57 #define GlobusXIOOpInc(_in_op) \ 61 GlobusXIODebugPrintf( \ 62 GLOBUS_XIO_DEBUG_STATE, \ 63 ("[%s:%d] Op @ 0x%x ref increased to %d:\n", _xio_name, __LINE__, \ 64 (_in_op), (_in_op)->ref)); \ 67 #define GlobusXIOOpDec(_in_op) \ 71 GlobusXIODebugPrintf( \ 72 GLOBUS_XIO_DEBUG_STATE, \ 73 ("[%s:%d] Op @ 0x%x ref decreased to %d:\n", _xio_name, __LINE__, \ 74 (_in_op), (_in_op)->ref)); \ 77 #define GlobusXIOObjToResult(_in_obj) \ 78 (_in_obj == NULL ? GLOBUS_SUCCESS : globus_error_put(_in_obj)) 80 #define GlobusXIOResultToObj(_in_res) \ 81 (_in_res == GLOBUS_SUCCESS ? NULL : globus_error_get(_in_res)) 83 #define GlobusXIOHandleStateChange(_h, _new) \ 86 globus_i_xio_handle_t * _l_h; \ 89 GlobusXIODebugPrintf( \ 90 GLOBUS_XIO_DEBUG_STATE, \ 91 ("[%s:%d] Handle @ 0x%x state change:\n" \ 97 globus_i_xio_handle_state_name_table[_l_h->state], \ 98 globus_i_xio_handle_state_name_table[_new])); \ 102 #define GlobusXIOOpStateChange(_op, _new) \ 105 globus_i_xio_op_t * _l_op; \ 108 GlobusXIODebugPrintf( \ 109 GLOBUS_XIO_DEBUG_STATE, \ 110 ("[%s:%d] Op @ 0x%x state change:\n" \ 116 globus_i_xio_op_state_name_table[_l_op->state], \ 117 globus_i_xio_op_state_name_table[_new])); \ 118 _l_op->state = _new; \ 121 #define GlobusXIOContextStateChange(_c, _new) \ 124 globus_i_xio_context_entry_t * _l_context; \ 127 GlobusXIODebugPrintf( \ 128 GLOBUS_XIO_DEBUG_STATE, \ 129 ("[%s:%d] Context @ 0x%x state change:\n" \ 135 globus_i_xio_context_state_name_table[_l_context->state], \ 136 globus_i_xio_context_state_name_table[_new])); \ 137 _l_context->state = _new; \ 140 #define GlobusXIODebugEnter() \ 141 GlobusXIODebugPrintf( \ 142 GLOBUS_XIO_DEBUG_TRACE, \ 143 ("[%s] Entering\n", _xio_name)) 145 #define GlobusXIODebugExit() \ 146 GlobusXIODebugPrintf( \ 147 GLOBUS_XIO_DEBUG_TRACE, \ 148 ("[%s] Exiting\n", _xio_name)) 150 #define GlobusXIODebugExitWithError() \ 151 GlobusXIODebugPrintf( \ 152 GLOBUS_XIO_DEBUG_TRACE, \ 153 ("[%s] Exiting with error\n", _xio_name)) 155 #define GlobusXIODebugInternalEnter() \ 156 GlobusXIODebugPrintf( \ 157 GLOBUS_XIO_DEBUG_INTERNAL_TRACE, \ 158 ("[%s] I Entering\n", _xio_name)) 160 #define GlobusXIODebugInternalExit() \ 161 GlobusXIODebugPrintf( \ 162 GLOBUS_XIO_DEBUG_INTERNAL_TRACE, \ 163 ("[%s] I Exiting\n", _xio_name)) 165 #define GlobusXIODebugInternalExitWithError() \ 166 GlobusXIODebugPrintf( \ 167 GLOBUS_XIO_DEBUG_INTERNAL_TRACE, \ 168 ("[%s] I Exiting with error\n", _xio_name)) 170 #define GlobusXIODebugInregisterOneShot() \ 171 GlobusXIODebugPrintf( \ 172 GLOBUS_XIO_DEBUG_INFO, \ 173 ("[%s] Registering one shot due to in_register.\n", _xio_name)) 175 #define GlobusXIODebugDelayedFinish() \ 176 GlobusXIODebugPrintf( \ 177 GLOBUS_XIO_DEBUG_INFO, \ 178 ("[%s] Delaying finish due to in_register and blocking op.\n", \ 181 #define GlobusXIOOperationCreate(_out_op, _in_c) \ 184 globus_i_xio_op_t * _X_op; \ 185 globus_i_xio_context_t * _X_c; \ 188 _X_op = (globus_i_xio_op_t * ) \ 189 globus_memory_pop_node(&_X_c->op_memory); \ 193 memset(_X_op, '\0', sizeof(globus_i_xio_op_t) + \ 194 (sizeof(globus_i_xio_op_entry_t) * (_X_c->stack_size - 1))); \ 195 _X_op->_op_context = _X_c; \ 196 _X_op->stack_size = _X_c->stack_size; \ 197 _X_op->progress = GLOBUS_TRUE; \ 198 _X_op->_op_ent_offset = -1; \ 207 #define GlobusIXIOClearCancel(op) \ 210 globus_i_xio_op_t * _op = (op); \ 216 globus_mutex_lock(&_op->_op_context->cancel_mutex); \ 217 if(_op->canceled == _op->ndx + 1) \ 221 globus_mutex_unlock(&_op->_op_context->cancel_mutex); \ 231 typedef struct gss_cred_id_desc_struct * gss_cred_id_t;
233 extern char * globus_i_xio_context_state_name_table[];
235 typedef enum globus_i_xio_context_state_e
237 GLOBUS_XIO_CONTEXT_STATE_NONE,
238 GLOBUS_XIO_CONTEXT_STATE_OPENING,
239 GLOBUS_XIO_CONTEXT_STATE_OPEN,
240 GLOBUS_XIO_CONTEXT_STATE_OPEN_FAILED,
241 GLOBUS_XIO_CONTEXT_STATE_EOF_RECEIVED,
242 GLOBUS_XIO_CONTEXT_STATE_EOF_DELIVERED,
243 GLOBUS_XIO_CONTEXT_STATE_EOF_RECEIVED_AND_CLOSING,
244 GLOBUS_XIO_CONTEXT_STATE_EOF_DELIVERED_AND_CLOSING,
245 GLOBUS_XIO_CONTEXT_STATE_CLOSING,
246 GLOBUS_XIO_CONTEXT_STATE_OPENING_AND_CLOSING,
247 GLOBUS_XIO_CONTEXT_STATE_CLOSED
248 } globus_i_xio_context_state_t;
250 extern char * globus_i_xio_handle_state_name_table[];
252 typedef enum globus_i_xio_handle_state_e
254 GLOBUS_XIO_HANDLE_STATE_NONE,
255 GLOBUS_XIO_HANDLE_STATE_CLIENT,
256 GLOBUS_XIO_HANDLE_STATE_ACCEPTED,
257 GLOBUS_XIO_HANDLE_STATE_OPENING,
258 GLOBUS_XIO_HANDLE_STATE_OPENING_FAILED,
259 GLOBUS_XIO_HANDLE_STATE_OPENING_AND_CLOSING,
260 GLOBUS_XIO_HANDLE_STATE_OPEN,
261 GLOBUS_XIO_HANDLE_STATE_OPEN_FAILED,
262 GLOBUS_XIO_HANDLE_STATE_CLOSING,
263 GLOBUS_XIO_HANDLE_STATE_CLOSED
264 } globus_i_xio_handle_state_t;
266 extern char * globus_i_xio_op_state_name_table[];
268 typedef enum globus_i_xio_op_state_e
270 GLOBUS_XIO_OP_STATE_NONE,
271 GLOBUS_XIO_OP_STATE_OPERATING,
272 GLOBUS_XIO_OP_STATE_TIMEOUT_PENDING,
273 GLOBUS_XIO_OP_STATE_FINISH_WAITING,
274 GLOBUS_XIO_OP_STATE_FINISHED
275 } globus_i_xio_op_state_t;
277 typedef enum globus_xio_server_state_e
279 GLOBUS_XIO_SERVER_STATE_NONE,
280 GLOBUS_XIO_SERVER_STATE_OPEN,
281 GLOBUS_XIO_SERVER_STATE_ACCEPTING,
282 GLOBUS_XIO_SERVER_STATE_COMPLETING,
283 GLOBUS_XIO_SERVER_STATE_CLOSE_PENDING,
284 GLOBUS_XIO_SERVER_STATE_CLOSING,
285 GLOBUS_XIO_SERVER_STATE_CLOSED
286 } globus_xio_server_state_t;
294 struct globus_i_xio_context_s;
295 struct globus_i_xio_op_s;
297 typedef struct globus_i_xio_monitor_s
300 } globus_i_xio_monitor_t;
303 globus_i_xio_monitor_init(
304 globus_i_xio_monitor_t * monitor);
307 globus_i_xio_monitor_destroy(
308 globus_i_xio_monitor_t * monitor);
310 typedef struct globus_i_xio_attr_ent_s
312 globus_xio_driver_t driver;
314 } globus_i_xio_attr_ent_t;
316 typedef struct globus_i_xio_attr_s
321 globus_reltime_t open_timeout_period;
323 globus_reltime_t read_timeout_period;
325 globus_reltime_t write_timeout_period;
327 globus_reltime_t close_timeout_period;
329 globus_xio_timeout_server_callback_t accept_timeout_cb;
330 globus_reltime_t accept_timeout_period;
340 gss_cred_id_t user_open_cred;
341 char * user_open_sbj;
342 char * user_open_username;
349 globus_i_xio_attr_ent_t * entry;
350 } globus_i_xio_attr_t;
352 typedef struct globus_i_xio_stack_s
356 globus_xio_driver_t pushing_driver;
357 } globus_i_xio_stack_t;
360 typedef struct globus_i_xio_server_entry_s
362 globus_xio_driver_t driver;
363 void * server_handle;
364 } globus_i_xio_server_entry_t;
368 typedef struct globus_i_xio_server_s
370 globus_i_xio_monitor_t * sd_monitor;
372 globus_xio_server_state_t state;
374 globus_xio_timeout_server_callback_t accept_timeout;
375 globus_reltime_t accept_timeout_period;
376 struct globus_i_xio_op_s * op;
381 int outstanding_operations;
388 char * contact_string;
391 globus_i_xio_server_entry_t entry[1];
392 } globus_i_xio_server_t;
394 typedef struct globus_i_xio_handle_s
396 globus_i_xio_monitor_t * sd_monitor;
400 struct globus_i_xio_context_s * context;
402 globus_i_xio_handle_state_t state;
408 struct globus_i_xio_op_s * open_op;
409 struct globus_i_xio_op_s * close_op;
415 globus_reltime_t open_timeout_period;
417 globus_reltime_t read_timeout_period;
419 globus_reltime_t write_timeout_period;
421 globus_reltime_t close_timeout_period;
422 } globus_i_xio_handle_t;
429 typedef struct globus_i_xio_context_entry_s
431 globus_xio_driver_t driver;
432 void * driver_handle;
435 globus_i_xio_context_state_t state;
436 int outstanding_operations;
444 struct globus_i_xio_op_s * open_op;
445 struct globus_i_xio_op_s * close_op;
448 struct globus_i_xio_context_s * whos_my_daddy;
449 } globus_i_xio_context_entry_t;
454 typedef struct globus_i_xio_context_s
460 globus_memory_t op_memory;
463 globus_i_xio_context_entry_t entry[1];
464 } globus_i_xio_context_t;
467 #define _op_ent_data_cb type_u.handle_s.data_cb 468 #define _op_ent_wait_for type_u.handle_s.wait_for_bytes 469 #define _op_ent_offset type_u.handle_s.offset 470 #define _op_ent_nbytes type_u.handle_s.nbytes 471 #define _op_ent_iovec type_u.handle_s.iovec 472 #define _op_ent_iovec_count type_u.handle_s.iovec_count 473 #define _op_ent_fake_iovec type_u.handle_s.fake_iovec 479 typedef struct globus_i_xio_op_entry_s
494 globus_xio_iovec_t * iovec;
496 globus_xio_iovec_t * fake_iovec;
510 } globus_i_xio_op_entry_t;
513 #define _op_data_cb data_cb 514 #define _op_iovec_cb iovec_cb 515 #define _op_cb callback_u.cb 516 #define _op_accept_cb callback_u.accept_cb 518 #define _op_handle type_u.handle_s.handle 519 #define _op_iovec type_u.handle_s.iovec 520 #define _op_iovec_count type_u.handle_s.iovec_count 521 #define _op_mem_iovec type_u.handle_s.mem_iovec 522 #define _op_context type_u.handle_s.context 523 #define _op_nbytes type_u.handle_s.nbytes 524 #define _op_wait_for type_u.handle_s.wait_for 525 #define _op_handle_timeout_cb type_u.handle_s.timeout_cb 527 #define _op_server type_u.server_s.server 528 #define _op_server_timeout_cb type_u.server_s.timeout_cb 541 globus_i_xio_blocked_thread_t;
545 typedef struct globus_i_xio_op_s
549 globus_i_xio_op_state_t state;
574 globus_i_xio_handle_t * handle;
576 globus_xio_iovec_t * iovec;
578 globus_xio_iovec_t mem_iovec;
583 globus_i_xio_context_t * context;
592 globus_i_xio_server_t * server;
593 globus_xio_timeout_server_callback_t timeout_cb;
604 globus_xio_driver_cancel_callback_t cancel_cb;
611 globus_i_xio_blocked_thread_t blocked_thread;
616 gss_cred_id_t user_open_cred;
617 char * user_open_sbj;
618 char * user_open_username;
622 globus_object_t * cached_obj;
629 globus_i_xio_op_entry_t entry[1];
632 typedef struct globus_i_xio_driver_s
638 globus_xio_driver_hook_t * hook;
639 globus_extension_handle_t extension_handle;
642 globus_xio_string_cntl_table_t * string_table;
643 globus_xio_string_cntl_table_t * handle_string_table;
655 globus_xio_driver_push_driver_t push_driver_func;
665 globus_xio_driver_link_cntl_t link_cntl_func;
677 } globus_i_xio_driver_t;
683 typedef struct globus_i_xio_blocking_s
689 globus_i_xio_op_t * op;
690 globus_xio_handle_t accepted_handle;
691 globus_xio_data_descriptor_t data_desc;
692 globus_object_t * error_obj;
693 } globus_i_xio_blocking_t;
695 typedef struct globus_i_xio_restart_s
697 globus_i_xio_op_t * op;
699 } globus_i_xio_restart_t;
701 globus_i_xio_blocking_t *
702 globus_i_xio_blocking_alloc();
705 globus_i_xio_blocking_destroy(
706 globus_i_xio_blocking_t * info);
712 globus_i_xio_server_close(
713 globus_xio_server_t xio_server,
718 globus_l_xio_driver_purge_read_eof(
719 globus_i_xio_context_entry_t * my_context);
722 globus_l_xio_driver_op_write_kickout(
726 globus_l_xio_driver_op_read_kickout(
730 globus_i_xio_driver_start_close(
731 globus_i_xio_op_t * op,
735 globus_l_xio_driver_op_close_kickout(
739 globus_l_xio_driver_op_accept_kickout(
743 globus_l_xio_driver_open_op_kickout(
747 globus_i_xio_driver_resume_op(
748 globus_i_xio_op_t * op);
754 (*globus_i_xio_timer_cb_t)(
757 typedef struct globus_i_xio_op_timer_s
759 globus_reltime_t minimal_delay;
765 } globus_i_xio_timer_t;
768 globus_i_xio_timer_init(
769 globus_i_xio_timer_t * timer);
772 globus_i_xio_timer_destroy(
773 globus_i_xio_timer_t * timer);
776 globus_i_xio_timer_register_timeout(
777 globus_i_xio_timer_t * timer,
780 globus_i_xio_timer_cb_t timeout_cb,
781 globus_reltime_t * timeout);
784 globus_i_xio_timer_unregister_timeout(
785 globus_i_xio_timer_t * timer,
788 globus_i_xio_context_t *
789 globus_i_xio_context_create(
793 globus_i_xio_context_destroy(
794 globus_i_xio_context_t * xio_context);
797 globus_i_xio_will_block_cb(
799 globus_thread_callback_index_t ndx,
803 globus_i_xio_pass_failed(
804 globus_i_xio_op_t * op,
805 globus_i_xio_context_entry_t * my_context,
810 globus_i_xio_handle_destroy(
811 globus_i_xio_handle_t * handle);
814 globus_i_xio_handle_dec(
815 globus_i_xio_handle_t * handle,
819 globus_i_xio_op_destroy(
820 globus_i_xio_op_t * op,
824 globus_i_xio_repass_write(
825 globus_i_xio_op_t * op);
828 globus_i_xio_repass_read(
829 globus_i_xio_op_t * op);
832 globus_i_xio_register_oneshot(
833 globus_i_xio_handle_t * handle,
839 typedef struct globus_i_xio_space_info_s
842 globus_i_xio_handle_t * handle;
846 } globus_i_xio_space_info_t;
849 globus_i_xio_close_handles(
850 globus_xio_driver_t driver);
853 globus_i_xio_operation_cancel(
854 globus_i_xio_op_t * op,
858 globus_i_xio_driver_deliver_op(
859 globus_i_xio_op_t * op,
864 globus_xio_driver_open_delivered(
865 globus_xio_operation_t in_op,
870 globus_xio_driver_write_delivered(
871 globus_xio_operation_t in_op,
876 globus_xio_driver_read_delivered(
877 globus_xio_operation_t op,
882 globus_i_xio_driver_dd_cntl(
883 globus_i_xio_op_t * op,
884 globus_xio_driver_t driver,
890 globus_i_xio_driver_handle_cntl(
891 globus_i_xio_context_t * context,
893 globus_xio_driver_t driver,
898 globus_i_xio_driver_attr_cntl(
899 globus_i_xio_attr_t * attr,
900 globus_xio_driver_t driver,
905 globus_i_xio_string_cntl_parser(
906 const char * env_str,
907 globus_xio_string_cntl_table_t * table,
912 extern globus_i_xio_timer_t globus_i_xio_timeout_timer;
913 extern globus_list_t * globus_i_xio_outstanding_handles_list;
914 extern globus_list_t * globus_i_xio_outstanding_servers_list;
void(* globus_xio_driver_callback_t)(globus_xio_operation_t op, globus_result_t result, void *user_arg)
Open and Close Callback Signature.
Definition: globus_xio_driver.h:273
Thread ID.
Definition: globus_thread.h:71
globus_result_t(* globus_xio_driver_server_cntl_t)(void *driver_server, int cmd, va_list ap)
Definition: globus_xio_driver.h:572
void(* globus_xio_driver_data_callback_t)(globus_xio_operation_t op, globus_result_t result, globus_size_t nbytes, void *user_arg)
Definition: globus_xio_driver.h:301
globus_result_t(* globus_xio_driver_transform_open_t)(const globus_xio_contact_t *contact_info, void *driver_link, void *driver_attr, globus_xio_operation_t op)
Open a handle.
Definition: globus_xio_driver.h:634
globus_result_t(* globus_xio_driver_server_accept_t)(void *driver_server, globus_xio_operation_t op)
Definition: globus_xio_driver.h:510
globus_result_t(* globus_xio_driver_link_destroy_t)(void *driver_link)
Definition: globus_xio_driver.h:598
globus_result_t(* globus_xio_driver_close_t)(void *driver_handle, void *driver_attr, globus_xio_operation_t op)
Close a handle.
Definition: globus_xio_driver.h:810
globus_result_t(* globus_xio_driver_handle_cntl_t)(void *handle, int cmd, va_list ap)
Definition: globus_xio_driver.h:776
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
int globus_bool_t
Boolean type.
Definition: globus_types.h:93
int globus_callback_handle_t
Periodic callback handle.
Definition: globus_callback.h:102
struct globus_fifo_s * globus_fifo_t
Definition: globus_fifo.h:48
enum globus_i_xio_op_type_e globus_xio_operation_type_t
globus_result_t(* globus_xio_driver_attr_cntl_t)(void *attr, int cmd, va_list ap)
Definition: globus_xio_driver.h:404
globus_result_t(* globus_xio_driver_server_init_t)(void *driver_attr, const globus_xio_contact_t *contact_info, globus_xio_operation_t op)
Definition: globus_xio_driver.h:435
List data type.
Definition: globus_list.h:44
void(* globus_xio_data_callback_t)(globus_xio_handle_t handle, globus_result_t result, globus_byte_t *buffer, globus_size_t len, globus_size_t nbytes, globus_xio_data_descriptor_t data_desc, void *user_arg)
Definition: globus_xio.h:601
Mutex.
Definition: globus_thread.h:107
globus_result_t(* globus_xio_driver_write_t)(void *driver_specific_handle, const globus_xio_iovec_t *iovec, int iovec_count, globus_xio_operation_t op)
Definition: globus_xio_driver.h:1034
globus_result_t(* globus_xio_driver_transport_open_t)(const globus_xio_contact_t *contact_info, void *driver_link, void *driver_attr, globus_xio_operation_t op)
Open a handle.
Definition: globus_xio_driver.h:645
void(* globus_xio_server_callback_t)(globus_xio_server_t server, void *user_arg)
Definition: globus_xio.h:372
Condition variable.
Definition: globus_thread.h:124
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
Headers common to all of Globus.
uint32_t globus_result_t
Definition: globus_types.h:99
globus_result_t(* globus_xio_driver_server_destroy_t)(void *driver_server)
Definition: globus_xio_driver.h:486
void(* globus_xio_callback_t)(globus_xio_handle_t handle, globus_result_t result, void *user_arg)
Definition: globus_xio.h:587
globus_result_t(* globus_xio_driver_attr_destroy_t)(void *driver_attr)
Definition: globus_xio_driver.h:381
globus_result_t(* globus_xio_driver_attr_init_t)(void **out_driver_attr)
Definition: globus_xio_driver.h:358
void(* globus_xio_accept_callback_t)(globus_xio_server_t server, globus_xio_handle_t handle, globus_result_t result, void *user_arg)
Definition: globus_xio.h:358
void(* globus_callback_func_t)(void *user_arg)
Globus callback prototype.
Definition: globus_callback.h:314
globus_result_t(* globus_xio_driver_read_t)(void *driver_specific_handle, const globus_xio_iovec_t *iovec, int iovec_count, globus_xio_operation_t op)
Definition: globus_xio_driver.h:884
int globus_callback_space_t
Callback space handle.
Definition: globus_callback.h:112
globus_bool_t(* globus_xio_timeout_callback_t)(globus_xio_handle_t handle, globus_xio_operation_type_t type, void *user_arg)
Definition: globus_xio.h:522
globus_result_t(* globus_xio_driver_attr_copy_t)(void **dst, void *src)
Definition: globus_xio_driver.h:369