![]() |
|
|||
0001 /** 0002 * @brief Load oracle drivers - static version 0003 * 0004 * @file oracle_common.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 0035 #ifndef _GNU_SOURCE 0036 #define _GNU_SOURCE 0037 #endif 0038 0039 #include <string.h> 0040 #include <stdio.h> 0041 #include <stdlib.h> 0042 0043 #include <ndrstandard.h> 0044 #include <ndebug.h> 0045 #include <atmi.h> 0046 #include <atmi_int.h> 0047 #include <sys_mqueue.h> 0048 0049 #include "atmi_shm.h" 0050 0051 #include <xa.h> 0052 #include <dlfcn.h> 0053 #include "oracle_common.h" 0054 /*---------------------------Externs------------------------------------*/ 0055 /*---------------------------Macros-------------------------------------*/ 0056 #define NDRX_ORA_TPGETCONN_MAGIC 0x1fca8e4c /**< magic */ 0057 #define NDRX_ORA_TPGETCONN_VERSION 1 /**< have xaoSvcCtx */ 0058 #define NDRX_ORA_XAOSVCCTX_SYMBOL "xaoSvcCtx" 0059 /*---------------------------Enums--------------------------------------*/ 0060 /*---------------------------Typedefs-----------------------------------*/ 0061 0062 /** 0063 * tpgetconn() struct values 0064 */ 0065 typedef struct 0066 { 0067 unsigned int magic; /**< Magic number */ 0068 long version; /**< record version */ 0069 void *xaoSvcCtx; /**< xaoSvcCtx handle, */ 0070 0071 } ndrx_ora_tpgetconn_t; 0072 0073 /*---------------------------Globals------------------------------------*/ 0074 /*---------------------------Statics------------------------------------*/ 0075 exprivate ndrx_ora_tpgetconn_t M_details; 0076 /*---------------------------Prototypes---------------------------------*/ 0077 0078 /** 0079 * Get connection detail 0080 * @return ptr to ndrx_ora_tpgetconn_t; 0081 */ 0082 void *xa_getconn_detail(void) 0083 { 0084 return (void *)&M_details; 0085 } 0086 0087 /* 0088 * The function is exported and dynamically retrieved after the module was 0089 * fetched 0090 */ 0091 struct xa_switch_t *ndrx_get_xa_switch_int(char *symbol, char *descr) 0092 { 0093 struct xa_switch_t * sw = NULL; 0094 void *handle = NULL; 0095 int ret = EXSUCCEED; 0096 NDRX_LOG(log_debug, "%s", descr); 0097 0098 memset(&M_details, 0, sizeof(M_details)); 0099 0100 M_details.magic = NDRX_ORA_TPGETCONN_MAGIC; 0101 M_details.version = NDRX_ORA_TPGETCONN_VERSION; 0102 0103 sw = (struct xa_switch_t * )dlsym( RTLD_DEFAULT, symbol ); 0104 if( sw == NULL ) 0105 { 0106 NDRX_LOG(log_debug, "%s symbol not found in " 0107 "process address space - loading .so!", symbol); 0108 0109 /* Loading the symbol... */ 0110 handle = dlopen (G_atmi_env.xa_rmlib, RTLD_NOW); 0111 if (!handle) 0112 { 0113 NDRX_LOG(log_error, "Failed to load XA Resource Manager lib [%s]: %s", 0114 G_atmi_env.xa_rmlib, dlerror()); 0115 EXFAIL_OUT(ret); 0116 } 0117 0118 /* resolve symbol now... */ 0119 if (NULL==(sw = (struct xa_switch_t * )dlsym( handle, symbol ))) 0120 { 0121 NDRX_LOG(log_error, "Oracle XA switch `%s' handler " 0122 "not found!", symbol); 0123 EXFAIL_OUT(ret); 0124 } 0125 0126 M_details.xaoSvcCtx = dlsym( handle, NDRX_ORA_XAOSVCCTX_SYMBOL ); 0127 0128 } 0129 else 0130 { 0131 /* try to load */ 0132 M_details.xaoSvcCtx = dlsym( RTLD_DEFAULT, NDRX_ORA_XAOSVCCTX_SYMBOL ); 0133 } 0134 0135 NDRX_LOG(log_debug, "xaoSvcCtx=%p", M_details.xaoSvcCtx); 0136 0137 /* set callback handle */ 0138 ndrx_xa_setgetconnn(xa_getconn_detail); 0139 0140 out: 0141 if (EXSUCCEED!=ret && NULL!=handle) 0142 { 0143 /* close the handle */ 0144 dlclose(handle); 0145 } 0146 0147 0148 return sw; 0149 } 0150 0151 /* 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 |
![]() ![]() |