![]() |
|
|||
0001 /** 0002 * @brief Enduro/X ATMI library thread local storage 0003 * 0004 * @file atmi_tls.h 0005 */ 0006 /* ----------------------------------------------------------------------------- 0007 * Enduro/X Middleware Platform for Distributed Transaction Processing 0008 * Copyright (C) 2009-2016, ATR Baltic, Ltd. All Rights Reserved. 0009 * Copyright (C) 2017-2023, Mavimax, Ltd. All Rights Reserved. 0010 * This software is released under one of the following licenses: 0011 * AGPL (with Java and Go exceptions) or Mavimax's license for commercial use. 0012 * See LICENSE file for full text. 0013 * ----------------------------------------------------------------------------- 0014 * AGPL license: 0015 * 0016 * This program is free software; you can redistribute it and/or modify it under 0017 * the terms of the GNU Affero General Public License, version 3 as published 0018 * by the Free Software Foundation; 0019 * 0020 * This program is distributed in the hope that it will be useful, but WITHOUT ANY 0021 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A 0022 * PARTICULAR PURPOSE. See the GNU Affero General Public License, version 3 0023 * for more details. 0024 * 0025 * You should have received a copy of the GNU Affero General Public License along 0026 * with this program; if not, write to the Free Software Foundation, Inc., 0027 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 0028 * 0029 * ----------------------------------------------------------------------------- 0030 * A commercial use license is available from Mavimax, Ltd 0031 * contact@mavimax.com 0032 * ----------------------------------------------------------------------------- 0033 */ 0034 #ifndef ATMI_TLS_H 0035 #define ATMI_TLS_H 0036 0037 #ifdef __cplusplus 0038 extern "C" { 0039 #endif 0040 0041 /*---------------------------Includes-----------------------------------*/ 0042 #include <pthread.h> 0043 #include <ndrstandard.h> 0044 #include <xa.h> 0045 #include <atmi_int.h> 0046 #include <xa_cmn.h> 0047 #include <tperror.h> 0048 #include <nstd_tls.h> 0049 #include <ubf_tls.h> 0050 #include <tx.h> 0051 #include <setjmp.h> 0052 #include <dirent.h> 0053 /*---------------------------Externs------------------------------------*/ 0054 /*---------------------------Macros-------------------------------------*/ 0055 0056 #define ATMI_TLS_MAGIG 0x39617cde 0057 0058 #define ATMI_TLS_ENTRY if (NDRX_UNLIKELY(NULL==G_atmi_tls)) \ 0059 {G_atmi_tls=(atmi_tls_t *)ndrx_atmi_tls_new(NULL, EXTRUE, EXTRUE);}; 0060 0061 #define NDRX_NDRXD_PING_SEQ_MAX 32000 /**< max ping sequence to reset */ 0062 0063 /* Feature #139 mvitolin, 09/05/2017 */ 0064 #define NDRX_SVCINSTALL_NOT 0 /**< Not doing service install */ 0065 #define NDRX_SVCINSTALL_DO 1 /**< Installing new service to SHM */ 0066 #define NDRX_SVCINSTALL_OVERWRITE 2 /**< Overwrite the already installed data */ 0067 0068 /*---------------------------Enums--------------------------------------*/ 0069 /*---------------------------Typedefs-----------------------------------*/ 0070 0071 /** 0072 * Memory base Q (current with static buffer) 0073 * but we could migrate to dynamically allocated buffers... 0074 */ 0075 typedef struct tpmemq tpmemq_t; 0076 struct tpmemq 0077 { 0078 char *buf; 0079 size_t len; 0080 size_t data_len; 0081 /* Linked list */ 0082 tpmemq_t *prev; 0083 tpmemq_t *next; 0084 }; 0085 0086 /** 0087 * TLS malloc'd block for qdisk_xa 0088 * Not moving all setting just purely to TLS, as this seems to 0089 * take a lot space and tls is used by all processes, thus it would 0090 * greatly increase memory footprint. 0091 */ 0092 typedef struct 0093 { 0094 /* Per thread data: */ 0095 int is_reg; /* Dynamic registration done? */ 0096 0097 /* 0098 * Due to fact that we might have multiple queued messages per resource manager 0099 * we will name the transaction files by this scheme: 0100 * - <XID_STR>-1|2|3|4|..|N 0101 * we will start the processing from N back to 1 so that if we crash and retry 0102 * the operation, we can handle all messages in system. 0103 */ 0104 char filename_base[PATH_MAX+1]; /**< base name of the file */ 0105 char filename_active[PATH_MAX+1]; /**< active file name */ 0106 char filename_prepared[PATH_MAX+1]; /**< prepared file name */ 0107 0108 /** List of prepared transactions */ 0109 struct dirent **recover_namelist; 0110 /** Current iterator of the recover */ 0111 int recover_i; 0112 /** last xid recovered in previous scan */ 0113 XID recover_last; 0114 /** is recover last loaded ? */ 0115 int recover_last_loaded; 0116 /** Is scanning open ? */ 0117 int recover_open; 0118 0119 } ndrx_qdisk_tls_t; 0120 0121 /** 0122 * ATMI library TLS 0123 * Here we will have a trick, if we get at TLS, then we must automatically suspend 0124 * the global transaction if one in progress. To that if we move to different 0125 * thread we can restore it... 0126 */ 0127 typedef struct 0128 { 0129 int magic; 0130 0131 /* atmi.c */ 0132 tp_command_call_t G_last_call; 0133 /* conversation.c */ 0134 int conv_cd;/*=1; first available */ 0135 /* unsigned callseq; - will be shared with tpcalls... global ...*//* = 0; */ 0136 0137 /* init.c */ 0138 int G_atmi_is_init;/* = 0; Is environment initialised */ 0139 atmi_lib_conf_t G_atmi_conf; /* ATMI library configuration */ 0140 tp_conversation_control_t G_tp_conversation_status[MAX_CONNECTIONS]; 0141 tp_conversation_control_t G_accepted_connection; 0142 0143 0144 /* tpcall.c */ 0145 long M_svc_return_code;/*=0; */ 0146 int tpcall_first; /* = TRUE; */ 0147 ndrx_stopwatch_t tpcall_start; 0148 call_descriptor_state_t G_call_state[MAX_ASYNC_CALLS]; 0149 int tpcall_get_cd; /* first available, we want test overlap!*/ 0150 /* unsigned tpcall_callseq; */ 0151 /*int tpcall_cd; = 0; */ 0152 0153 /* We need a enqueued list of messages */ 0154 tpmemq_t *memq; /* Message enqueued in memory... */ 0155 /* EX_SPIN_LOCKDECL(memq_lock); - not needed this TLS for one thread 0156 * thus memq is processed by same thread only*/ 0157 0158 /* tperror.c */ 0159 char M_atmi_error_msg_buf[MAX_TP_ERROR_LEN+1]; /* = {EOS}; */ 0160 int M_atmi_error;/* = TPMINVAL; */ 0161 short M_atmi_reason;/* = NDRX_XA_ERSN_NONE; XA reason, default */ 0162 char errbuf[MAX_TP_ERROR_LEN+1]; 0163 /* xa.c */ 0164 int M_is_curtx_init;/* = FALSE; */ 0165 atmi_xa_curtx_t G_atmi_xa_curtx; 0166 0167 /* xautils.c */ 0168 XID xid; /* handler for new XID */ 0169 int global_tx_suspended; /* TODO: suspend the global txn */ 0170 TPTRANID tranid; /* suspended transaction id - suspended global tx... */ 0171 0172 int is_auto; /* is this auto-allocated (thus do the auto-free) */ 0173 /* mutex lock (so that no two parallel threads work with same tls */ 0174 MUTEX_VAR(mutex); /* initialize later with PTHREAD_MUTEX_INITIALIZER */ 0175 0176 /* have the transport for other's TLSes 0177 * used by tpgetctxt() and tpsetctxt() 0178 */ 0179 nstd_tls_t *p_nstd_tls; 0180 ubf_tls_t *p_ubf_tls; 0181 0182 int is_associated_with_thread; /* Is current context associated with thread? */ 0183 0184 /* unsolicited notification processing */ 0185 void (*p_unsol_handler) (char *data, long len, long flags); 0186 0187 TPINIT client_init_data; 0188 0189 int ndrxd_ping_seq; /**< NDRXD daemon ping sequence sent */ 0190 0191 0192 /* TX Specification related: */ 0193 0194 /** 0195 * Shall tx_commit() return when transaction is completed 0196 * or return when logged for completion? 0197 * Default: Wait for complete. 0198 */ 0199 COMMIT_RETURN tx_commit_return; 0200 0201 /** 0202 * Shall caller start new transaction when commit/abort is called? 0203 * Default NO 0204 */ 0205 TRANSACTION_CONTROL tx_transaction_control; 0206 0207 /** 0208 * What is transaction timeout? In seconds. 0209 */ 0210 TRANSACTION_TIMEOUT tx_transaction_timeout; 0211 0212 ndrx_ctx_priv_t integpriv; /**< integration private data */ 0213 0214 jmp_buf call_ret_env; /**< for MT server where to return */ 0215 0216 /* hook tpacall no service... */ 0217 int (*pf_tpacall_noservice_hook)(char *svc, char *data, 0218 long len, long flags); 0219 0220 buffer_obj_t nullbuf; /**< so that we have place where to set call infos */ 0221 0222 /** default priority setting used for calls */ 0223 int prio; 0224 long prio_flags; 0225 int prio_last; 0226 0227 int tout; /**< thread specific timeout setting, all */ 0228 int tout_next; /**< thread specific timeout setting, only next */ 0229 int tout_next_eff; /**< Effective timeout next */ 0230 0231 int tmnull_is_open; /**< Null swith is open ? */ 0232 int tmnull_rmid; /**< Null switch RMID */ 0233 0234 /* Shared between threads: */ 0235 int qdisk_is_open; 0236 int qdisk_rmid; 0237 0238 long atmisrv_reply_type; /**< libatmisrv flags */ 0239 0240 ndrx_qdisk_tls_t *qdisk_tls; 0241 0242 } atmi_tls_t; 0243 /*---------------------------Globals------------------------------------*/ 0244 extern NDRX_API __thread atmi_tls_t *G_atmi_tls; /* Enduro/X standard library TLS */ 0245 /*---------------------------Statics------------------------------------*/ 0246 /*---------------------------Prototypes---------------------------------*/ 0247 #ifdef __cplusplus 0248 } 0249 #endif 0250 0251 #endif /* ATMI_CONTEXT_H */ 0252 0253 /* vim: set ts=4 sw=4 et smartindent: */
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.1.0 LXR engine. The LXR team |
![]() ![]() |