[ https://issues.apache.org/jira/browse/TRAFODION-2821?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16473775#comment-16473775 ]
ASF GitHub Bot commented on TRAFODION-2821: ------------------------------------------- Github user selvaganesang commented on a diff in the pull request: https://github.com/apache/trafodion/pull/1562#discussion_r187837665 --- Diff: core/sqf/src/tm/tmlib.cpp --- @@ -2817,35 +2833,44 @@ void TMLIB::initialize() // This call has been changed so that the node count includes spare nodes, so // will give the wrong value for iv_node_count. msg_mon_get_node_info(&iv_node_count, MAX_NODES, NULL); - is_initialized(true); + iv_initialized = true; // We don't use gv_tmlib_initialized but set it here just to keep things aligned. gv_tmlib_initialized = true; + initMutex_->unlock(); } - - // ------------------------------------------------------------------- // TMLIB::initJNI // Initialize JNI interface // Only used on demand - if you do this in TMLIB::initialize // it gets called when it may not be used and conflicts with udrserv. // ------------------------------------------------------------------- -void TMLIB::initJNI() +int TMLIB::initJNI() { - int lv_err = 0; - static bool ls_initialized = false; + int lv_err = 0; - //sleep(30); - if (ls_initialized) - return; - - short lv_result = setupJNI(); - if (lv_result) { - fprintf(stderr, "setupJNI returned error %d in TMLIB::initJNI. Exiting.\n", lv_result); - fflush(stderr); - abort(); + if ((lv_err = initJNIEnv()) != 0) + return lv_err; + if (isInitialized()) + return 0; + _tlp_jenv->PopLocalFrame(NULL); + if (javaMethodsInitialized_) + return JavaObjectInterfaceTM::init((char *)hbasetxclient_classname, hbasetxclient_class, TMLibJavaMethods_, JM_LAST_HBASETXCLIENT, javaMethodsInitialized_); + else + { + initMutex_->lock(); + if (javaMethodsInitialized_) { + initMutex_->unlock(); + return JavaObjectInterfaceTM::init((char *)hbasetxclient_classname, hbasetxclient_class, TMLibJavaMethods_, JM_LAST_HBASETXCLIENT, javaMethodsInitialized_); + } + short lv_result = setupJNI(); + if (lv_result) { + fprintf(stderr, "setupJNI returned error %d in TMLIB::initJNI. Exiting.\n", lv_result); + fflush(stderr); + abort(); + } } - + initMutex_->unlock(); --- End diff -- Yes. I will move it within the else block because initMutext_ is locked in the else block. > Trafodion core code base needs to be thread safe > ------------------------------------------------- > > Key: TRAFODION-2821 > URL: https://issues.apache.org/jira/browse/TRAFODION-2821 > Project: Apache Trafodion > Issue Type: Improvement > Components: sql-general > Affects Versions: any > Reporter: Selvaganesan Govindarajan > Assignee: Selvaganesan Govindarajan > Priority: Major > Fix For: 2.3 > > > This is the covering trafodion jira to make trafodion core code base to be > thread safe. It is needed to ensure that type T2 JDBC driver hosted on > platform can be enabled to support multi-threaded JDBC applications. > [TRAFODION-2783] is one such case. -- This message was sent by Atlassian JIRA (v7.6.3#76005)