globus_i_xio.h

00001 /*
00002  * Copyright 1999-2006 University of Chicago
00003  * 
00004  * Licensed under the Apache License, Version 2.0 (the "License");
00005  * you may not use this file except in compliance with the License.
00006  * You may obtain a copy of the License at
00007  * 
00008  * http://www.apache.org/licenses/LICENSE-2.0
00009  * 
00010  * Unless required by applicable law or agreed to in writing, software
00011  * distributed under the License is distributed on an "AS IS" BASIS,
00012  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00013  * See the License for the specific language governing permissions and
00014  * limitations under the License.
00015  */
00016 
00017 #ifndef GLOBUS_DONT_DOCUMENT_INTERNAL
00018 
00019 #if !defined(GLOBUS_I_XIO_H)
00020 #define GLOBUS_I_XIO_H 1
00021 
00022 #include "globus_xio.h"
00023 #include "globus_xio_driver.h"
00024 #include "globus_common.h"
00025 #include "globus_xio_util.h"
00026 #include "globus_xio_load.h"
00027 
00028 #define GLOBUS_XIO_ATTR_ARRAY_BASE_SIZE             16
00029 #define GLOBUS_XIO_HANDLE_DEFAULT_OPERATION_COUNT   4
00030 
00031 /***************************************************************************
00032  *                         internal macros
00033  *                         ---------------
00034  **************************************************************************/
00035 
00036 #define GlobusXIOCurrentBlockedThread(blocked_thread)                       \
00037     if (globus_i_am_only_thread())                                          \
00038     {                                                                       \
00039         blocked_thread.thread = globus_thread_self();                       \
00040     }                                                                       \
00041     else                                                                    \
00042     {                                                                       \
00043         blocked_thread.depth = globus_callback_space_get_depth(             \
00044                 GLOBUS_CALLBACK_GLOBAL_SPACE);                              \
00045     }
00046 #define GlobusXIOBlockedThreadMatchesCurrentThread(a)                       \
00047     (globus_i_am_only_thread()                                              \
00048         ? (a.depth ==                                                       \
00049             globus_callback_space_get_depth(GLOBUS_CALLBACK_GLOBAL_SPACE))  \
00050         : globus_thread_equal(a.thread, globus_thread_self()))
00051 
00052 GlobusDebugDeclare(GLOBUS_XIO);
00053 
00054 #define GlobusXIODebugPrintf(level, message)                                \
00055     GlobusDebugPrintf(GLOBUS_XIO, level, message)
00056 
00057 #define GlobusXIOOpInc(_in_op)                                              \
00058 do                                                                          \
00059 {                                                                           \
00060     (_in_op)->ref++;                                                        \
00061     GlobusXIODebugPrintf(                                                   \
00062         GLOBUS_XIO_DEBUG_STATE,                                             \
00063         ("[%s:%d] Op @ 0x%x ref increased to %d:\n", _xio_name, __LINE__,   \
00064          (_in_op), (_in_op)->ref));                                         \
00065 } while(0)
00066 
00067 #define GlobusXIOOpDec(_in_op)                                              \
00068 do                                                                          \
00069 {                                                                           \
00070     (_in_op)->ref--;                                                        \
00071     GlobusXIODebugPrintf(                                                   \
00072         GLOBUS_XIO_DEBUG_STATE,                                             \
00073         ("[%s:%d] Op @ 0x%x ref decreased to %d:\n", _xio_name, __LINE__,   \
00074          (_in_op), (_in_op)->ref));                                         \
00075 } while(0)
00076 
00077 #define GlobusXIOObjToResult(_in_obj)                                       \
00078     (_in_obj == NULL ? GLOBUS_SUCCESS : globus_error_put(_in_obj))
00079 
00080 #define GlobusXIOResultToObj(_in_res)                                       \
00081     (_in_res == GLOBUS_SUCCESS ? NULL : globus_error_get(_in_res))
00082 
00083 #define GlobusXIOHandleStateChange(_h, _new)                                \
00084 do                                                                          \
00085 {                                                                           \
00086     globus_i_xio_handle_t *             _l_h;                               \
00087                                                                             \
00088     _l_h = (_h);                                                            \
00089     GlobusXIODebugPrintf(                                                   \
00090         GLOBUS_XIO_DEBUG_STATE,                                             \
00091         ("[%s:%d] Handle @ 0x%x state change:\n"                            \
00092          "    From:%s\n"                                                    \
00093          "    to:  %s\n",                                                   \
00094             _xio_name,                                                      \
00095             __LINE__,                                                       \
00096             _l_h,                                                           \
00097             globus_i_xio_handle_state_name_table[_l_h->state],              \
00098             globus_i_xio_handle_state_name_table[_new]));                   \
00099    _l_h->state = _new;                                                      \
00100 } while(0)
00101 
00102 #define GlobusXIOOpStateChange(_op, _new)                                   \
00103 do                                                                          \
00104 {                                                                           \
00105     globus_i_xio_op_t *                 _l_op;                              \
00106                                                                             \
00107     _l_op = (_op);                                                          \
00108     GlobusXIODebugPrintf(                                                   \
00109         GLOBUS_XIO_DEBUG_STATE,                                             \
00110         ("[%s:%d] Op @ 0x%x state change:\n"                                \
00111          "    From:%s\n"                                                    \
00112          "    to:  %s\n",                                                   \
00113             _xio_name,                                                      \
00114             __LINE__,                                                       \
00115             _l_op,                                                          \
00116             globus_i_xio_op_state_name_table[_l_op->state],                 \
00117             globus_i_xio_op_state_name_table[_new]));                       \
00118    _l_op->state = _new;                                                     \
00119 } while(0)
00120 
00121 #define GlobusXIOContextStateChange(_c, _new)                               \
00122 do                                                                          \
00123 {                                                                           \
00124     globus_i_xio_context_entry_t *      _l_context;                         \
00125                                                                             \
00126     _l_context = (_c);                                                      \
00127     GlobusXIODebugPrintf(                                                   \
00128         GLOBUS_XIO_DEBUG_STATE,                                             \
00129         ("[%s:%d] Context @ 0x%x state change:\n"                           \
00130          "    From:%s\n"                                                    \
00131          "    to:  %s\n",                                                   \
00132             _xio_name,                                                      \
00133             __LINE__,                                                       \
00134             _l_context,                                                     \
00135             globus_i_xio_context_state_name_table[_l_context->state],       \
00136             globus_i_xio_context_state_name_table[_new]));                  \
00137    _l_context->state = _new;                                                \
00138 } while(0)
00139 
00140 #define GlobusXIODebugEnter()                                               \
00141     GlobusXIODebugPrintf(                                                   \
00142         GLOBUS_XIO_DEBUG_TRACE,                                             \
00143         ("[%s] Entering\n", _xio_name))
00144 
00145 #define GlobusXIODebugExit()                                                \
00146     GlobusXIODebugPrintf(                                                   \
00147         GLOBUS_XIO_DEBUG_TRACE,                                             \
00148         ("[%s] Exiting\n", _xio_name))
00149 
00150 #define GlobusXIODebugExitWithError()                                       \
00151     GlobusXIODebugPrintf(                                                   \
00152         GLOBUS_XIO_DEBUG_TRACE,                                             \
00153         ("[%s] Exiting with error\n", _xio_name))
00154 
00155 #define GlobusXIODebugInternalEnter()                                       \
00156     GlobusXIODebugPrintf(                                                   \
00157         GLOBUS_XIO_DEBUG_INTERNAL_TRACE,                                    \
00158         ("[%s] I Entering\n", _xio_name))
00159 
00160 #define GlobusXIODebugInternalExit()                                        \
00161     GlobusXIODebugPrintf(                                                   \
00162         GLOBUS_XIO_DEBUG_INTERNAL_TRACE,                                    \
00163         ("[%s] I Exiting\n", _xio_name))
00164 
00165 #define GlobusXIODebugInternalExitWithError()                               \
00166     GlobusXIODebugPrintf(                                                   \
00167         GLOBUS_XIO_DEBUG_INTERNAL_TRACE,                                    \
00168         ("[%s] I Exiting with error\n", _xio_name))
00169 
00170 #define GlobusXIODebugInregisterOneShot()                                   \
00171     GlobusXIODebugPrintf(                                                   \
00172         GLOBUS_XIO_DEBUG_INFO,                                              \
00173         ("[%s] Registering one shot due to in_register.\n", _xio_name))
00174 
00175 #define GlobusXIODebugDelayedFinish()                                       \
00176     GlobusXIODebugPrintf(                                                   \
00177         GLOBUS_XIO_DEBUG_INFO,                                              \
00178         ("[%s] Delaying finish due to in_register and blocking op.\n",      \
00179         _xio_name))
00180 
00181 #define GlobusXIOOperationCreate(_out_op, _in_c)                            \
00182 do                                                                          \
00183 {                                                                           \
00184     globus_i_xio_op_t *                 _X_op;                              \
00185     globus_i_xio_context_t *            _X_c;                               \
00186                                                                             \
00187     _X_c = (_in_c);                                                         \
00188     _X_op = (globus_i_xio_op_t * )                                          \
00189             globus_memory_pop_node(&_X_c->op_memory);                       \
00190     if(_X_op != NULL)                                                       \
00191     {                                                                       \
00192         /* sets deliver_op to NONE */                                       \
00193         memset(_X_op, '\0', sizeof(globus_i_xio_op_t) +                     \
00194             (sizeof(globus_i_xio_op_entry_t) * (_X_c->stack_size - 1)));    \
00195         _X_op->_op_context = _X_c;                                          \
00196         _X_op->stack_size = _X_c->stack_size;                               \
00197         _X_op->progress = GLOBUS_TRUE;                                      \
00198         _X_op->_op_ent_offset = -1;                                         \
00199     }                                                                       \
00200     _out_op = _X_op;                                                        \
00201 } while(0)
00202 
00203 
00204 /* if index == the level at which a cancel was requested then we reset the 
00205  * canceled flag for the operation. 
00206  */
00207 #define GlobusIXIOClearCancel(op)                                           \
00208 do                                                                          \
00209 {                                                                           \
00210     globus_i_xio_op_t *                 _op = (op);                         \
00211     /* op->ndx is source_ndx + 1, canceled is source_ndx + 2 */             \
00212     /* so, source_ndx == op->ndx + 1                         */             \
00213     /* see globus_i_xio_operation_cancel                     */             \
00214     if(_op->canceled)                                                       \
00215     {                                                                       \
00216         globus_mutex_lock(&_op->_op_context->cancel_mutex);                 \
00217         if(_op->canceled == _op->ndx + 1)                                   \
00218         {                                                                   \
00219             _op->canceled = 0;                                              \
00220         }                                                                   \
00221         globus_mutex_unlock(&_op->_op_context->cancel_mutex);               \
00222     }                                                                       \
00223 } while(0)
00224 
00225 /***************************************************************************
00226  *                 state and type enumerations
00227  *                 ---------------------------
00228  **************************************************************************/
00229 
00230 /* forward declare for setting cred */
00231 typedef struct gss_cred_id_desc_struct * gss_cred_id_t;
00232 
00233 extern char * globus_i_xio_context_state_name_table[];
00234 
00235 typedef enum globus_i_xio_context_state_e
00236 {
00237     GLOBUS_XIO_CONTEXT_STATE_NONE,
00238     GLOBUS_XIO_CONTEXT_STATE_OPENING,
00239     GLOBUS_XIO_CONTEXT_STATE_OPEN,
00240     GLOBUS_XIO_CONTEXT_STATE_OPEN_FAILED,
00241     GLOBUS_XIO_CONTEXT_STATE_EOF_RECEIVED,
00242     GLOBUS_XIO_CONTEXT_STATE_EOF_DELIVERED,
00243     GLOBUS_XIO_CONTEXT_STATE_EOF_RECEIVED_AND_CLOSING,
00244     GLOBUS_XIO_CONTEXT_STATE_EOF_DELIVERED_AND_CLOSING,
00245     GLOBUS_XIO_CONTEXT_STATE_CLOSING,
00246     GLOBUS_XIO_CONTEXT_STATE_OPENING_AND_CLOSING,
00247     GLOBUS_XIO_CONTEXT_STATE_CLOSED
00248 } globus_i_xio_context_state_t;
00249 
00250 extern char * globus_i_xio_handle_state_name_table[];
00251 
00252 typedef enum globus_i_xio_handle_state_e
00253 {
00254     GLOBUS_XIO_HANDLE_STATE_NONE,
00255     GLOBUS_XIO_HANDLE_STATE_CLIENT,
00256     GLOBUS_XIO_HANDLE_STATE_ACCEPTED,
00257     GLOBUS_XIO_HANDLE_STATE_OPENING,
00258     GLOBUS_XIO_HANDLE_STATE_OPENING_FAILED,
00259     GLOBUS_XIO_HANDLE_STATE_OPENING_AND_CLOSING,
00260     GLOBUS_XIO_HANDLE_STATE_OPEN,
00261     GLOBUS_XIO_HANDLE_STATE_OPEN_FAILED,
00262     GLOBUS_XIO_HANDLE_STATE_CLOSING,
00263     GLOBUS_XIO_HANDLE_STATE_CLOSED
00264 } globus_i_xio_handle_state_t;
00265 
00266 extern char * globus_i_xio_op_state_name_table[];
00267 
00268 typedef enum globus_i_xio_op_state_e
00269 {
00270     GLOBUS_XIO_OP_STATE_NONE,
00271     GLOBUS_XIO_OP_STATE_OPERATING,
00272     GLOBUS_XIO_OP_STATE_TIMEOUT_PENDING,
00273     GLOBUS_XIO_OP_STATE_FINISH_WAITING,
00274     GLOBUS_XIO_OP_STATE_FINISHED
00275 } globus_i_xio_op_state_t;
00276 
00277 typedef enum globus_xio_server_state_e
00278 {
00279     GLOBUS_XIO_SERVER_STATE_NONE,
00280     GLOBUS_XIO_SERVER_STATE_OPEN,
00281     GLOBUS_XIO_SERVER_STATE_ACCEPTING,
00282     GLOBUS_XIO_SERVER_STATE_COMPLETING,
00283     GLOBUS_XIO_SERVER_STATE_CLOSE_PENDING,
00284     GLOBUS_XIO_SERVER_STATE_CLOSING,
00285     GLOBUS_XIO_SERVER_STATE_CLOSED
00286 } globus_xio_server_state_t;
00287 
00288 /***************************************************************************
00289  *                  Internally exposed data structures
00290  *                  ----------------------------------
00291  **************************************************************************/
00292 
00293 
00294 struct globus_i_xio_context_s;
00295 struct globus_i_xio_op_s;
00296 
00297 typedef struct globus_i_xio_monitor_s
00298 {
00299     int                                 count;
00300 } globus_i_xio_monitor_t;
00301 
00302 void
00303 globus_i_xio_monitor_init(
00304     globus_i_xio_monitor_t *            monitor);
00305 
00306 void
00307 globus_i_xio_monitor_destroy(
00308     globus_i_xio_monitor_t *            monitor);
00309 
00310 typedef struct globus_i_xio_attr_ent_s
00311 {
00312     globus_xio_driver_t                 driver;
00313     void *                              driver_data;
00314 } globus_i_xio_attr_ent_t;
00315 
00316 typedef struct globus_i_xio_attr_s
00317 {
00318     globus_bool_t                       unloaded;
00319     
00320     globus_xio_timeout_callback_t       open_timeout_cb;
00321     globus_reltime_t                    open_timeout_period;
00322     globus_xio_timeout_callback_t       read_timeout_cb;
00323     globus_reltime_t                    read_timeout_period;
00324     globus_xio_timeout_callback_t       write_timeout_cb;
00325     globus_reltime_t                    write_timeout_period;
00326     globus_xio_timeout_callback_t       close_timeout_cb;
00327     globus_reltime_t                    close_timeout_period;
00328 
00329     globus_xio_timeout_server_callback_t accept_timeout_cb;
00330     globus_reltime_t                    accept_timeout_period;
00331 
00332     globus_bool_t                       cancel_open;
00333     globus_bool_t                       cancel_close;
00334     globus_bool_t                       cancel_read;
00335     globus_bool_t                       cancel_write;
00336 
00337     globus_bool_t                       no_cancel;
00338     void *                              timeout_arg;
00339 
00340     gss_cred_id_t                       user_open_cred;
00341     char *                              user_open_sbj;
00342     char *                              user_open_username;
00343     char *                              user_open_pw;
00344 
00345     globus_callback_space_t             space;
00346 
00347     int                                 max;
00348     int                                 ndx;
00349     globus_i_xio_attr_ent_t *           entry;
00350 } globus_i_xio_attr_t;
00351 
00352 typedef struct globus_i_xio_stack_s
00353 {
00354     int                                 size;
00355     globus_list_t *                     driver_stack;
00356     globus_xio_driver_t                 pushing_driver;
00357 } globus_i_xio_stack_t;
00358 
00359 
00360 typedef struct globus_i_xio_server_entry_s
00361 {
00362     globus_xio_driver_t                 driver;
00363     void *                              server_handle;
00364 } globus_i_xio_server_entry_t;
00365 /* 
00366  *  
00367  */
00368 typedef struct globus_i_xio_server_s
00369 {
00370     globus_i_xio_monitor_t *            sd_monitor;
00371     
00372     globus_xio_server_state_t           state;
00373 
00374     globus_xio_timeout_server_callback_t accept_timeout;
00375     globus_reltime_t                    accept_timeout_period;
00376     struct globus_i_xio_op_s *          op;
00377 
00378     globus_xio_server_callback_t        cb;
00379     void *                              user_arg;
00380 
00381     int                                 outstanding_operations;
00382 
00383     int                                 ref;
00384     globus_mutex_t                      mutex;
00385     globus_callback_space_t             space;
00386 
00387     globus_bool_t                       blocking;
00388     char *                              contact_string;
00389     
00390     int                                 stack_size;
00391     globus_i_xio_server_entry_t         entry[1];
00392 } globus_i_xio_server_t;
00393 
00394 typedef struct globus_i_xio_handle_s
00395 {
00396     globus_i_xio_monitor_t *            sd_monitor;
00397 
00398     globus_list_t *                     cb_list;
00399     int                                 ref;
00400     struct globus_i_xio_context_s *     context;
00401 
00402     globus_i_xio_handle_state_t         state;
00403 
00404     /* since only 1 open or close can be outstanding at a time we don't
00405        need a list */
00406     globus_list_t *                     write_op_list;
00407     globus_list_t *                     read_op_list;
00408     struct globus_i_xio_op_s *          open_op;
00409     struct globus_i_xio_op_s *          close_op;
00410 
00411     void *                              timeout_arg;
00412 
00413     globus_callback_space_t             space;
00414     globus_xio_timeout_callback_t       open_timeout_cb;
00415     globus_reltime_t                    open_timeout_period;
00416     globus_xio_timeout_callback_t       read_timeout_cb;
00417     globus_reltime_t                    read_timeout_period;
00418     globus_xio_timeout_callback_t       write_timeout_cb;
00419     globus_reltime_t                    write_timeout_period;
00420     globus_xio_timeout_callback_t       close_timeout_cb;
00421     globus_reltime_t                    close_timeout_period;
00422 } globus_i_xio_handle_t;
00423 
00424 /*
00425  *  represents an entry in the array of open handles.
00426  *
00427  *  each entry is mapped to a driver in the stack
00428  */
00429 typedef struct globus_i_xio_context_entry_s
00430 {
00431     globus_xio_driver_t                 driver;
00432     void *                              driver_handle;
00433 
00434     /* each level must implement the entire state machine */
00435     globus_i_xio_context_state_t        state;
00436     int                                 outstanding_operations;
00437     int                                 read_operations;
00438     int                                 eof_operations;
00439     int                                 pending_reads;
00440 
00441     /* is this hacky? */
00442     globus_bool_t                       close_started;
00443 
00444     struct globus_i_xio_op_s *          open_op;
00445     struct globus_i_xio_op_s *          close_op;
00446     globus_list_t *                     eof_op_list;
00447     globus_fifo_t                       pending_read_queue;
00448     struct globus_i_xio_context_s *     whos_my_daddy;
00449 } globus_i_xio_context_entry_t;
00450 
00451 /* 
00452  *  a stretchy array
00453  */
00454 typedef struct globus_i_xio_context_s
00455 {
00456     /* handle has a reference and every entry has a reference */
00457     int                                 ref;
00458     int                                 stack_size;
00459 
00460     globus_memory_t                     op_memory;
00461     globus_mutex_t                      mutex;
00462     globus_mutex_t                      cancel_mutex;
00463     globus_i_xio_context_entry_t        entry[1];
00464 } globus_i_xio_context_t;
00465 
00466 /* MACROS for accessing the op_entry structure unin elements */
00467 #define _op_ent_data_cb                 type_u.handle_s.data_cb
00468 #define _op_ent_wait_for                type_u.handle_s.wait_for_bytes
00469 #define _op_ent_offset                  type_u.handle_s.offset
00470 #define _op_ent_nbytes                  type_u.handle_s.nbytes
00471 #define _op_ent_iovec                   type_u.handle_s.iovec
00472 #define _op_ent_iovec_count             type_u.handle_s.iovec_count
00473 #define _op_ent_fake_iovec              type_u.handle_s.fake_iovec
00474 
00475 /*
00476  *  represents a entry in an array of operations.  Each entry
00477  *  is mapped to a driver at the same index.
00478  */
00479 typedef struct globus_i_xio_op_entry_s
00480 {
00481     /* callback info arrays */
00482     globus_xio_operation_type_t         type;
00483     globus_xio_driver_callback_t        cb;
00484     void *                              user_arg;
00485 
00486     union
00487     {
00488         /* handle op entries */
00489         struct
00490         {
00491             globus_xio_driver_data_callback_t data_cb;
00492             globus_size_t               wait_for_bytes;
00493             globus_size_t               nbytes;
00494             globus_xio_iovec_t *        iovec;
00495             int                         iovec_count;
00496             globus_xio_iovec_t *        fake_iovec;
00497         } handle_s;
00498     } type_u;
00499     globus_bool_t                       in_register;
00500     globus_bool_t                       is_limited;
00501 
00502     void *                              dd;
00503     void *                              link;
00504     void *                              open_attr;
00505     void *                              close_attr;
00506     int                                 prev_ndx;
00507     int                                 next_ndx;
00508 
00509     globus_xio_operation_type_t *       deliver_type;
00510 } globus_i_xio_op_entry_t;
00511 
00512 
00513 #define _op_data_cb                     data_cb
00514 #define _op_iovec_cb                    iovec_cb
00515 #define _op_cb                          callback_u.cb
00516 #define _op_accept_cb                   callback_u.accept_cb
00517 
00518 #define _op_handle                      type_u.handle_s.handle
00519 #define _op_iovec                       type_u.handle_s.iovec
00520 #define _op_iovec_count                 type_u.handle_s.iovec_count
00521 #define _op_mem_iovec                   type_u.handle_s.mem_iovec
00522 #define _op_context                     type_u.handle_s.context
00523 #define _op_nbytes                      type_u.handle_s.nbytes
00524 #define _op_wait_for                    type_u.handle_s.wait_for
00525 #define _op_handle_timeout_cb           type_u.handle_s.timeout_cb
00526 
00527 #define _op_server                      type_u.server_s.server
00528 #define _op_server_timeout_cb           type_u.server_s.timeout_cb
00529 
00536 typedef union
00537 {
00538     globus_thread_t                     thread;
00539     int                                 depth;
00540 }
00541 globus_i_xio_blocked_thread_t;
00542 /*
00543  *  represents a requested io operation (open close read or write).
00544  */
00545 typedef struct globus_i_xio_op_s
00546 {
00547     /* operation type */
00548     globus_xio_operation_type_t         type;
00549     globus_i_xio_op_state_t             state;
00550 
00551     globus_bool_t                       is_user_dd;
00552 
00553     /*
00554      * user callbacks.  only 1 will be used per operation
00555      */
00556     union
00557     {
00558         globus_xio_callback_t           cb;
00559         globus_xio_accept_callback_t    accept_cb;
00560     }callback_u;
00561 
00562     globus_xio_data_callback_t          data_cb;
00563     globus_xio_iovec_callback_t         iovec_cb;
00564     void *                              user_arg;
00565    
00566     /*
00567      *  Union operation members that will not overlap together
00568      */
00569     union
00570     { 
00571         /* handle op stuff */
00572         struct
00573         {
00574             globus_i_xio_handle_t *     handle;
00575 
00576             globus_xio_iovec_t *        iovec;
00577             int                         iovec_count;
00578             globus_xio_iovec_t          mem_iovec;
00579 
00580             globus_size_t               nbytes;
00581 
00582             /* convenience pointer, really owned by handle */
00583             globus_i_xio_context_t *    context;
00584             /* data descriptor */
00585             globus_size_t               wait_for;
00586             globus_off_t                offset;
00587             globus_xio_timeout_callback_t timeout_cb;
00588         } handle_s;
00589         /* server op stuff */
00590         struct
00591         {
00592             globus_i_xio_server_t *     server;
00593             globus_xio_timeout_server_callback_t timeout_cb;
00594         } server_s;
00595     } type_u;
00596 
00597     /* flag to determine if timeout should happen */
00598     globus_bool_t                       progress;
00599 
00600     /* reference count for destruction */
00601     int                                 ref;
00602 
00603     /* members for cancellation */
00604     globus_xio_driver_cancel_callback_t cancel_cb;
00605     void *                              cancel_arg;
00606     int                                 canceled;
00607     globus_bool_t                       block_timeout;
00608 
00609     globus_bool_t                       restarted;
00610     globus_bool_t                       blocking;
00611     globus_i_xio_blocked_thread_t       blocked_thread;
00612     globus_bool_t                       finished_delayed;
00613 
00614     /* just stash away the cred to open so that the driver can interrogate
00615         it.  */
00616     gss_cred_id_t                       user_open_cred;
00617     char *                              user_open_sbj;
00618     char *                              user_open_username;
00619     char *                              user_open_pw;
00620     
00621     /* result code saved in op for kickouts */
00622     globus_object_t *                   cached_obj;
00623 
00624     /* size of the arrays */
00625     int                                 stack_size;
00626     /* current index in the driver stack */
00627     int                                 ndx;
00628     /* entry for each thing driver in the stack */
00629     globus_i_xio_op_entry_t             entry[1];
00630 } globus_i_xio_op_t;
00631 
00632 typedef struct globus_i_xio_driver_s
00633 {
00634     char *                              name;
00635     void *                              user_data;
00636     void *                              wrap_data;
00637     /* these are filled in by the driver loader */
00638     globus_xio_driver_hook_t *          hook;
00639     globus_extension_handle_t           extension_handle;
00640     globus_bool_t                       extension_activated;
00641 
00642     globus_xio_string_cntl_table_t *    string_table;
00643     globus_xio_string_cntl_table_t *    handle_string_table;
00644 
00645     /*
00646      *  main io interface functions
00647      */
00648     globus_xio_driver_transform_open_t  transform_open_func;
00649     globus_xio_driver_transport_open_t  transport_open_func;
00650     globus_xio_driver_close_t           close_func;
00651     globus_xio_driver_read_t            read_func;
00652     globus_xio_driver_write_t           write_func;
00653     globus_xio_driver_handle_cntl_t     handle_cntl_func;
00654 
00655     globus_xio_driver_push_driver_t     push_driver_func;
00656 
00657     /*
00658      * server
00659      */
00660     globus_xio_driver_server_init_t     server_pre_init_func;
00661     globus_xio_driver_server_init_t     server_init_func;
00662     globus_xio_driver_server_accept_t   server_accept_func;
00663     globus_xio_driver_server_destroy_t  server_destroy_func;
00664     globus_xio_driver_server_cntl_t     server_cntl_func;
00665     globus_xio_driver_link_cntl_t       link_cntl_func;
00666     globus_xio_driver_link_destroy_t    link_destroy_func;
00667 
00668     /*
00669      *  driver attr functions.  All or none may be NULL
00670      *
00671      *   data descriptor is done with attr
00672      */
00673     globus_xio_driver_attr_init_t       attr_init_func;
00674     globus_xio_driver_attr_copy_t       attr_copy_func;
00675     globus_xio_driver_attr_cntl_t       attr_cntl_func;
00676     globus_xio_driver_attr_destroy_t    attr_destroy_func;
00677 } globus_i_xio_driver_t;
00678 
00679 
00680 /*
00681  *  wrapper struct
00682  */
00683 typedef struct globus_i_xio_blocking_s
00684 {
00685     globus_mutex_t                      mutex;
00686     globus_cond_t                       cond;
00687     globus_bool_t                       done;
00688     globus_size_t                       nbytes;
00689     globus_i_xio_op_t *                 op;
00690     globus_xio_handle_t                 accepted_handle;
00691     globus_xio_data_descriptor_t        data_desc;
00692     globus_object_t *                   error_obj;
00693 } globus_i_xio_blocking_t;
00694 
00695 typedef struct globus_i_xio_restart_s
00696 {
00697     globus_i_xio_op_t *                 op;
00698     globus_bool_t                       restarted;
00699 } globus_i_xio_restart_t;
00700 
00701 globus_i_xio_blocking_t *
00702 globus_i_xio_blocking_alloc();
00703 
00704 void
00705 globus_i_xio_blocking_destroy(
00706     globus_i_xio_blocking_t *           info);
00707 
00708 /*************************************************************************
00709  *                     internal function signatures
00710  ************************************************************************/
00711 globus_result_t
00712 globus_i_xio_server_close(
00713     globus_xio_server_t                 xio_server,
00714     globus_xio_server_callback_t        cb,
00715     void *                              user_arg);
00716 
00717 void
00718 globus_l_xio_driver_purge_read_eof(
00719     globus_i_xio_context_entry_t *      my_context);
00720 
00721 void
00722 globus_l_xio_driver_op_write_kickout(
00723     void *                              user_arg);
00724 
00725 void
00726 globus_l_xio_driver_op_read_kickout(
00727     void *                              user_arg);
00728 
00729 globus_result_t
00730 globus_i_xio_driver_start_close(
00731     globus_i_xio_op_t *                 op,
00732     globus_bool_t                       can_fail);
00733 
00734 void
00735 globus_l_xio_driver_op_close_kickout(
00736     void *                              user_arg);
00737 
00738 void
00739 globus_l_xio_driver_op_accept_kickout(
00740     void *                              user_arg);
00741 
00742 void
00743 globus_l_xio_driver_open_op_kickout(
00744     void *                              user_arg);
00745 
00746 void
00747 globus_i_xio_driver_resume_op(
00748     globus_i_xio_op_t *                 op);
00749     
00750 /*
00751  *  time stuff
00752  */
00753 typedef globus_bool_t
00754 (*globus_i_xio_timer_cb_t)(
00755     void *                              datum);
00756 
00757 typedef struct globus_i_xio_op_timer_s
00758 {
00759     globus_reltime_t                    minimal_delay;
00760     globus_mutex_t                      mutex;
00761     globus_cond_t                       cond;
00762     globus_list_t *                     op_list;
00763     globus_bool_t                       running;
00764     globus_callback_handle_t            periodic_handle;
00765 } globus_i_xio_timer_t;
00766 
00767 void
00768 globus_i_xio_timer_init(
00769     globus_i_xio_timer_t *              timer);
00770 
00771 void
00772 globus_i_xio_timer_destroy(
00773     globus_i_xio_timer_t *              timer);
00774 
00775 void
00776 globus_i_xio_timer_register_timeout(
00777     globus_i_xio_timer_t *              timer,
00778     void *                              datum,
00779     globus_bool_t *                     progress_ptr,
00780     globus_i_xio_timer_cb_t             timeout_cb,
00781     globus_reltime_t *                  timeout);
00782 
00783 globus_bool_t
00784 globus_i_xio_timer_unregister_timeout(
00785     globus_i_xio_timer_t *              timer,
00786     void *                              datum);
00787 
00788 globus_i_xio_context_t *
00789 globus_i_xio_context_create(
00790     int                                 stack_size);
00791 
00792 void
00793 globus_i_xio_context_destroy(
00794     globus_i_xio_context_t *            xio_context);
00795 
00796 void
00797 globus_i_xio_will_block_cb(
00798     int                                 space,
00799     globus_thread_callback_index_t      ndx,
00800     void *                              user_args);
00801 
00802 void
00803 globus_i_xio_pass_failed(
00804     globus_i_xio_op_t *                 op,
00805     globus_i_xio_context_entry_t *      my_context,
00806     globus_bool_t *                     close,
00807     globus_bool_t *                     destroy_handle);
00808 
00809 void
00810 globus_i_xio_handle_destroy(
00811     globus_i_xio_handle_t *             handle);
00812 
00813 void
00814 globus_i_xio_handle_dec(
00815     globus_i_xio_handle_t *             handle,
00816     globus_bool_t *                     destroy_handle);
00817 
00818 void
00819 globus_i_xio_op_destroy(
00820     globus_i_xio_op_t *                 op,
00821     globus_bool_t *                     destroy_handle);
00822 
00823 globus_result_t
00824 globus_i_xio_repass_write(
00825     globus_i_xio_op_t *                 op);
00826 
00827 globus_result_t
00828 globus_i_xio_repass_read(
00829     globus_i_xio_op_t *                 op);
00830 
00831 void
00832 globus_i_xio_register_oneshot(
00833     globus_i_xio_handle_t *             handle,
00834     globus_callback_func_t              cb,
00835     void *                              user_arg,
00836     globus_callback_space_t             space);
00837 
00838 
00839 typedef struct globus_i_xio_space_info_s
00840 {
00841     globus_bool_t                       unregister;
00842     globus_i_xio_handle_t *             handle;
00843     globus_callback_handle_t            ch;
00844     globus_callback_func_t              func;
00845     void *                              user_arg;
00846 } globus_i_xio_space_info_t;
00847 
00848 void
00849 globus_i_xio_close_handles(
00850     globus_xio_driver_t                 driver);
00851 
00852 globus_result_t
00853 globus_i_xio_operation_cancel(
00854     globus_i_xio_op_t *                 op,
00855     int                                 source_ndx);
00856 
00857 void
00858 globus_i_xio_driver_deliver_op(
00859     globus_i_xio_op_t *                 op,
00860     int                                 ndx,
00861     globus_xio_operation_type_t         deliver_type);
00862 
00863 void
00864 globus_xio_driver_open_delivered(
00865     globus_xio_operation_t              in_op,
00866     int                                 in_ndx,
00867     globus_xio_operation_type_t *       deliver_type);
00868 
00869 void
00870 globus_xio_driver_write_delivered(
00871     globus_xio_operation_t              in_op,
00872     int                                 in_ndx,
00873     globus_xio_operation_type_t *       deliver_type);
00874 
00875 void
00876 globus_xio_driver_read_delivered(
00877     globus_xio_operation_t              op,
00878     int                                 in_ndx,
00879     globus_xio_operation_type_t *       deliver_type);
00880 
00881 globus_result_t
00882 globus_i_xio_driver_dd_cntl(
00883     globus_i_xio_op_t *                 op,
00884     globus_xio_driver_t                 driver,
00885     globus_xio_operation_type_t         type,
00886     int                                 cmd,
00887     va_list                             ap);
00888 
00889 globus_result_t
00890 globus_i_xio_driver_handle_cntl(
00891     globus_i_xio_context_t *            context,
00892     int                                 start_ndx,
00893     globus_xio_driver_t                 driver,
00894     int                                 cmd,
00895     va_list                             ap);
00896 
00897 globus_result_t
00898 globus_i_xio_driver_attr_cntl(
00899     globus_i_xio_attr_t *               attr,
00900     globus_xio_driver_t                 driver,
00901     int                                 cmd,
00902     va_list                             ap);
00903 
00904 globus_result_t
00905 globus_i_xio_string_cntl_parser(
00906     const char *                        env_str,
00907     globus_xio_string_cntl_table_t *    table,
00908     void *                              attr,
00909     globus_xio_driver_attr_cntl_t       attr_func);
00910 
00911 
00912 extern globus_i_xio_timer_t             globus_i_xio_timeout_timer;
00913 extern globus_list_t *                  globus_i_xio_outstanding_handles_list;
00914 extern globus_list_t *                  globus_i_xio_outstanding_servers_list;
00915 extern globus_list_t *                  globus_i_xio_outstanding_attrs_list;
00916 extern globus_list_t *                  globus_i_xio_outstanding_dds_list;
00917 extern globus_mutex_t                   globus_i_xio_mutex;
00918 extern globus_cond_t                    globus_i_xio_cond;
00919 
00920 #endif /* GLOBUS_I_XIO_H */
00921 
00922 #endif /* GLOBUS_DONT_DOCUMENT_INTERNAL */

Generated on 5 Nov 2016 for globus_xio by  doxygen 1.4.7