![]() |
|
|||
0001 /** 0002 * @brief Tmsrv server - transaction monitor, XA util part 0003 * 0004 * @file xasrvutil.c 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 #include <stdio.h> 0035 #include <stdlib.h> 0036 #include <string.h> 0037 #include <errno.h> 0038 #include <regex.h> 0039 #include <utlist.h> 0040 0041 #include <ndebug.h> 0042 #include <atmi.h> 0043 #include <atmi_int.h> 0044 #include <typed_buf.h> 0045 #include <ndrstandard.h> 0046 #include <ubf.h> 0047 #include <Exfields.h> 0048 0049 #include <exnet.h> 0050 #include <ndrxdcmn.h> 0051 0052 #include "tmsrv.h" 0053 #include "../libatmisrv/srv_int.h" 0054 #include <xa_cmn.h> 0055 #include <atmi_int.h> 0056 /*---------------------------Externs------------------------------------*/ 0057 /*---------------------------Macros-------------------------------------*/ 0058 /*---------------------------Enums--------------------------------------*/ 0059 /*---------------------------Typedefs-----------------------------------*/ 0060 /*---------------------------Globals------------------------------------*/ 0061 /*---------------------------Statics------------------------------------*/ 0062 exprivate MUTEX_LOCKDECL(M_xid_gen_lock); /* Thread locking for xid generation */ 0063 /*---------------------------Prototypes---------------------------------*/ 0064 0065 /** 0066 * Generate new transaction id 0067 * @param xid 0068 */ 0069 expublic void atmi_xa_new_xid(XID *xid) 0070 { 0071 exuuid_t uuid_val; 0072 atmi_lib_env_t *atmi_env = ndrx_get_G_atmi_env(); 0073 unsigned char rmid = (unsigned char)atmi_env->xa_rmid; 0074 short node_id = (short) htons(G_tmsrv_cfg.vnodeid); 0075 short srv_id = (short) htons(G_srv_id); 0076 0077 /* Do the locking, so that we get unique xids... */ 0078 MUTEX_LOCK_V(M_xid_gen_lock); 0079 0080 /* we will include here following additional data: 0081 * - cluster node_id 0082 * - endurox server_id 0083 */ 0084 0085 xid->formatID = NDRX_XID_FORMAT_ID; 0086 0087 /* Oracle JDBC driver requires max lenght xid otherwise it gives 0088 * java.sql.SQLException: ORA-25352: no current transaction 0089 */ 0090 /* xid->gtrid_length = sizeof(exuuid_t); */ 0091 /* xid->bqual_length = sizeof(unsigned char) + sizeof(short) + sizeof(short); */ 0092 0093 xid->gtrid_length = MAXGTRIDSIZE; 0094 xid->bqual_length = MAXBQUALSIZE; 0095 0096 memset(xid->data, 0, XIDDATASIZE); /* this is not necessary, but... */ 0097 ndrx_cid_generate((unsigned char)tpgetnodeid(), uuid_val); 0098 memcpy(xid->data, uuid_val, sizeof(exuuid_t)); 0099 0100 /*Bug #228 - using incorrect rmid field was using short from env instead of rmid (uchar)*/ 0101 NDRX_LOG(log_debug, "New xid, rmid=%d(%c), node_id=%hd, srv_id=%hd", 0102 (int)rmid, rmid, node_id, srv_id); 0103 0104 0105 memcpy(xid->data + NDRX_XID_TRID_LEN, (char *)&rmid, sizeof(unsigned char)); 0106 /* Have an additional infos for transaction id... */ 0107 memcpy(xid->data 0108 +NDRX_XID_TRID_LEN 0109 +sizeof(unsigned char) 0110 ,(char *)&(node_id), sizeof(short)); 0111 memcpy(xid->data 0112 +NDRX_XID_TRID_LEN 0113 +sizeof(unsigned char) 0114 +sizeof(short) 0115 ,(char *)&(srv_id), sizeof(short)); 0116 0117 /* copy first block to second, to have the same values in the block.. */ 0118 memcpy(xid->data+MAXGTRIDSIZE, xid->data, MAXBQUALSIZE); 0119 0120 MUTEX_UNLOCK_V(M_xid_gen_lock); 0121 } 0122 0123 /* 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 |
![]() ![]() |