Hi Vu Ack
Thanks Lennart > -----Original Message----- > From: Vu Minh Nguyen [mailto:vu.m.ngu...@dektech.com.au] > Sent: den 16 maj 2016 08:58 > To: mathi.naic...@oracle.com; Lennart Lund > Cc: opensaf-devel@lists.sourceforge.net > Subject: [PATCH 1 of 1] log: make using immutilWrapperProfile thread safe > [#1807] > > osaf/services/saf/logsv/lgs/lgs_amf.cc | 20 +- > osaf/services/saf/logsv/lgs/lgs_config.cc | 72 ++++++--- > osaf/services/saf/logsv/lgs/lgs_evt.cc | 3 - > osaf/services/saf/logsv/lgs/lgs_imm.cc | 196 > ++++++++++------------------ > osaf/services/saf/logsv/lgs/lgs_imm_gcfg.cc | 21 --- > osaf/services/saf/logsv/lgs/lgs_main.cc | 15 ++ > osaf/services/saf/logsv/lgs/lgs_util.cc | 1 - > 7 files changed, 141 insertions(+), 187 deletions(-) > > > LOG has several threads which were using same global > `immutilWrapperProfile` variable > when invoking `immutil_` utility. This caused race condition. > > Make whole process using one immutilWrapperProfile. If any place wants > to use different profile, call IMM API directly. > > diff --git a/osaf/services/saf/logsv/lgs/lgs_amf.cc > b/osaf/services/saf/logsv/lgs/lgs_amf.cc > --- a/osaf/services/saf/logsv/lgs/lgs_amf.cc > +++ b/osaf/services/saf/logsv/lgs/lgs_amf.cc > @@ -24,8 +24,6 @@ > #include "lgs_config.h" > #include "immutil.h" > > -extern struct ImmutilWrapperProfile immutilWrapperProfile; > - > static void close_all_files() > { > log_stream_t *stream; > @@ -78,8 +76,6 @@ static SaAisErrorT amf_active_state_hand > } > > done: > - immutilWrapperProfile.nTries = 20; /* Reset retry time to > more normal value. */ > - immutilWrapperProfile.errorsAreFatal = 1; > /* Update role independent of stream processing */ > lgs_cb->mds_role = V_DEST_RL_ACTIVE; > TRACE_LEAVE(); > @@ -127,13 +123,16 @@ static SaAisErrorT amf_standby_state_han > > ********************************************************** > *******************/ > static SaAisErrorT amf_quiescing_state_handler(lgs_cb_t *cb, SaInvocationT > invocation) > { > + SaAisErrorT ais_rc = SA_AIS_OK; > + > TRACE_ENTER2("HA QUIESCING request"); > close_all_files(); > > /* Give up our IMM OI implementer role */ > - immutilWrapperProfile.errorsAreFatal = 0; > - (void)immutil_saImmOiImplementerClear(cb->immOiHandle); > - immutilWrapperProfile.errorsAreFatal = 1; > + ais_rc = immutil_saImmOiImplementerClear(cb- > >immOiHandle); > + if (ais_rc != SA_AIS_OK) { > + LOG_WA("immutil_saImmOiImplementerClear > failed: %s", saf_error(ais_rc)); > + } > > lgs_stop_gcfg_applier(); > > @@ -162,9 +161,10 @@ static SaAisErrorT amf_quiesced_state_ha > close_all_files(); > > /* Give up our IMM OI implementer role */ > - immutilWrapperProfile.errorsAreFatal = 0; > - (void)immutil_saImmOiImplementerClear(cb->immOiHandle); > - immutilWrapperProfile.errorsAreFatal = 1; > + rc = immutil_saImmOiImplementerClear(cb->immOiHandle); > + if (rc != SA_AIS_OK) { > + LOG_WA("immutil_saImmOiImplementerClear > failed: %s", saf_error(rc)); > + } > > lgs_stop_gcfg_applier(); > > diff --git a/osaf/services/saf/logsv/lgs/lgs_config.cc > b/osaf/services/saf/logsv/lgs/lgs_config.cc > --- a/osaf/services/saf/logsv/lgs/lgs_config.cc > +++ b/osaf/services/saf/logsv/lgs/lgs_config.cc > @@ -36,7 +36,6 @@ > #include "lgs_file.h" > #include "lgs.h" > > -extern struct ImmutilWrapperProfile immutilWrapperProfile; > static SaVersionT immVersion = { 'A', 2, 11 }; > > /* Mutex for making read and write of configuration data thread safe */ > @@ -792,15 +791,22 @@ static void read_logsv_config_obj_2() { > SaImmAttrValuesT_2 **attributes; > int i = 0; > int n; > - > - int asetting = immutilWrapperProfile.errorsAreFatal; > SaAisErrorT om_rc = SA_AIS_OK; > > TRACE_ENTER(); > > /* NOTE: immutil init will osaf_assert if error */ > - (void) immutil_saImmOmInitialize(&omHandle, NULL, > &immVersion); > - (void) immutil_saImmOmAccessorInitialize(omHandle, > &accessorHandle); > + om_rc = immutil_saImmOmInitialize(&omHandle, NULL, > &immVersion); > + if (om_rc != SA_AIS_OK) { > + LOG_ER("immutil_saImmOmInitialize failed: > %s", saf_error(om_rc)); > + osaf_abort(0); > + } > + > + om_rc = immutil_saImmOmAccessorInitialize(omHandle, > &accessorHandle); > + if (om_rc != SA_AIS_OK) { > + LOG_ER("immutil_saImmOmAccessorInitialize > failed: %s", saf_error(om_rc)); > + osaf_abort(0); > + } > > n = snprintf((char *) objectName.value, > SA_MAX_NAME_LENGTH, "%s", > > LGS_IMM_LOG_CONFIGURATION); > @@ -811,8 +817,13 @@ static void read_logsv_config_obj_2() { > objectName.length = strlen((char *) objectName.value); > > /* Get all attributes of the object */ > - if (immutil_saImmOmAccessorGet_2(accessorHandle, > &objectName, NULL, &attributes) != SA_AIS_OK) { > - LOG_NO("%s immutil_saImmOmAccessorGet_2 > Fail", __FUNCTION__); > + if ((om_rc = immutil_saImmOmAccessorGet_2( > + accessorHandle, > + &objectName, > + NULL, > + &attributes)) != SA_AIS_OK) { > + LOG_NO("%s immutil_saImmOmAccessorGet_2 > Fail: %s", > + __FUNCTION__, saf_error(om_rc)); > goto done; > } > else { > @@ -903,16 +914,17 @@ static void read_logsv_config_obj_2() { > > done: > /* Do not abort if error when finalizing */ > - immutilWrapperProfile.errorsAreFatal = 0; /* Disable immutil > abort */ > om_rc = immutil_saImmOmAccessorFinalize(accessorHandle); > if (om_rc != SA_AIS_OK) { > - LOG_NO("%s > immutil_saImmOmAccessorFinalize() Fail %d",__FUNCTION__, om_rc); > + LOG_NO("%s > immutil_saImmOmAccessorFinalize() Fail %s", > + __FUNCTION__, saf_error(om_rc)); > } > + > om_rc = immutil_saImmOmFinalize(omHandle); > if (om_rc != SA_AIS_OK) { > - LOG_NO("%s immutil_saImmOmFinalize() Fail > %d",__FUNCTION__, om_rc); > + LOG_NO("%s immutil_saImmOmFinalize() Fail > %s", > + __FUNCTION__, saf_error(om_rc)); > } > - immutilWrapperProfile.errorsAreFatal = asetting; /* Enable > again */ > > TRACE_LEAVE(); > } > @@ -1389,10 +1401,11 @@ void conf_runtime_obj_create(SaImmOiHand > parent_name.length = strlen((char *) parent_name.value); > parent_name_p = &parent_name; > > - rc = saImmOiRtObjectCreate_2(immOiHandle, > - > const_cast<SaImmClassNameT>("OpenSafLogCurrentConfig"), > - parent_name_p, > - attrValues); > + rc = immutil_saImmOiRtObjectCreate_2( > + immOiHandle, > + > const_cast<SaImmClassNameT>("OpenSafLogCurrentConfig"), > + parent_name_p, > + attrValues); > > if (rc == SA_AIS_ERR_EXIST) { > TRACE("Server runtime configuration object > already exist"); > @@ -1417,6 +1430,7 @@ void conf_runtime_obj_hdl(SaImmOiHandleT > int i = 0; > char *str_val = NULL; > SaUint32T u32_val = 0; > + SaAisErrorT ais_rc = SA_AIS_OK; > > TRACE_ENTER(); > > @@ -1425,77 +1439,77 @@ void conf_runtime_obj_hdl(SaImmOiHandleT > if (!strcmp(attributeName, > LOG_ROOT_DIRECTORY)) { > str_val = (char *) > > lgs_cfg_get(LGS_IMM_LOG_ROOT_DIRECTORY); > - > (void)immutil_update_one_rattr(immOiHandle, > + ais_rc = > immutil_update_one_rattr(immOiHandle, > > LGS_CFG_RUNTIME_OBJECT, > attributeName, > SA_IMM_ATTR_SASTRINGT, > &str_val); > } else if (!strcmp(attributeName, > LOG_DATA_GROUPNAME)) { > str_val = (char *) > > lgs_cfg_get(LGS_IMM_DATA_GROUPNAME); > - > (void)immutil_update_one_rattr(immOiHandle, > + ais_rc = > immutil_update_one_rattr(immOiHandle, > > LGS_CFG_RUNTIME_OBJECT, > attributeName, > SA_IMM_ATTR_SASTRINGT, > &str_val); > } else if (!strcmp(attributeName, > LOG_STREAM_FILE_FORMAT)) { > str_val = (char *) > > lgs_cfg_get(LGS_IMM_LOG_STREAM_FILE_FORMAT); > - > (void)immutil_update_one_rattr(immOiHandle, > + ais_rc = > immutil_update_one_rattr(immOiHandle, > LGS_CFG_RUNTIME_OBJECT, > attributeName, > SA_IMM_ATTR_SASTRINGT, > &str_val); > } else if (!strcmp(attributeName, > LOG_MAX_LOGRECSIZE)) { > u32_val = *(SaUint32T *) > > lgs_cfg_get(LGS_IMM_LOG_MAX_LOGRECSIZE); > - (void) > immutil_update_one_rattr(immOiHandle, > + ais_rc = > immutil_update_one_rattr(immOiHandle, > > LGS_CFG_RUNTIME_OBJECT, > attributeName, > SA_IMM_ATTR_SAUINT32T, > &u32_val); > } else if (!strcmp(attributeName, > LOG_STREAM_SYSTEM_HIGH_LIMIT)) { > u32_val = *(SaUint32T *) > > lgs_cfg_get(LGS_IMM_LOG_STREAM_SYSTEM_HIGH_LIMIT); > - (void) > immutil_update_one_rattr(immOiHandle, > + ais_rc = > immutil_update_one_rattr(immOiHandle, > > LGS_CFG_RUNTIME_OBJECT, > attributeName, > SA_IMM_ATTR_SAUINT32T, > &u32_val); > } else if (!strcmp(attributeName, > LOG_STREAM_SYSTEM_LOW_LIMIT)) { > u32_val = *(SaUint32T *) > > lgs_cfg_get(LGS_IMM_LOG_STREAM_SYSTEM_LOW_LIMIT); > - (void) > immutil_update_one_rattr(immOiHandle, > + ais_rc = > immutil_update_one_rattr(immOiHandle, > > LGS_CFG_RUNTIME_OBJECT, > attributeName, > SA_IMM_ATTR_SAUINT32T, > &u32_val); > } else if (!strcmp(attributeName, > LOG_STREAM_APP_HIGH_LIMIT)) { > u32_val = *(SaUint32T *) > > lgs_cfg_get(LGS_IMM_LOG_STREAM_APP_HIGH_LIMIT); > - (void) > immutil_update_one_rattr(immOiHandle, > + ais_rc = > immutil_update_one_rattr(immOiHandle, > > LGS_CFG_RUNTIME_OBJECT, > attributeName, > SA_IMM_ATTR_SAUINT32T, > &u32_val); > } else if (!strcmp(attributeName, > LOG_STREAM_APP_LOW_LIMIT)) { > u32_val = *(SaUint32T *) > > lgs_cfg_get(LGS_IMM_LOG_STREAM_APP_LOW_LIMIT); > - (void) > immutil_update_one_rattr(immOiHandle, > + ais_rc = > immutil_update_one_rattr(immOiHandle, > > LGS_CFG_RUNTIME_OBJECT, > attributeName, > SA_IMM_ATTR_SAUINT32T, > &u32_val); > } else if (!strcmp(attributeName, > LOG_MAX_APPLICATION_STREAMS)) { > u32_val = *(SaUint32T *) > > lgs_cfg_get(LGS_IMM_LOG_MAX_APPLICATION_STREAMS); > - (void) > immutil_update_one_rattr(immOiHandle, > + ais_rc = > immutil_update_one_rattr(immOiHandle, > > LGS_CFG_RUNTIME_OBJECT, > attributeName, > SA_IMM_ATTR_SAUINT32T, > &u32_val); > } else if (!strcmp(attributeName, > LOG_FILE_IO_TIMEOUT)) { > u32_val = *(SaUint32T *) > > lgs_cfg_get(LGS_IMM_FILEHDL_TIMEOUT); > - (void) > immutil_update_one_rattr(immOiHandle, > + ais_rc = > immutil_update_one_rattr(immOiHandle, > > LGS_CFG_RUNTIME_OBJECT, > attributeName, > SA_IMM_ATTR_SAUINT32T, > &u32_val); > } else if (!strcmp(attributeName, > LOG_FILE_SYS_CONFIG)) { > u32_val = *(SaUint32T *) > > lgs_cfg_get(LGS_IMM_LOG_FILESYS_CFG); > - (void) > immutil_update_one_rattr(immOiHandle, > + ais_rc = > immutil_update_one_rattr(immOiHandle, > > LGS_CFG_RUNTIME_OBJECT, > attributeName, > SA_IMM_ATTR_SAUINT32T, > &u32_val); > @@ -1503,6 +1517,12 @@ void conf_runtime_obj_hdl(SaImmOiHandleT > TRACE("%s: unknown attribute > %s", > __FUNCTION__, > attributeName); > } > + > + if (ais_rc != SA_AIS_OK) { > + > LOG_ER("immutil_update_one_rattr (%s) failed: %s", > + attributeName, > saf_error(ais_rc)); > + osaf_abort(0); > + } > } > > TRACE_LEAVE(); > diff --git a/osaf/services/saf/logsv/lgs/lgs_evt.cc > b/osaf/services/saf/logsv/lgs/lgs_evt.cc > --- a/osaf/services/saf/logsv/lgs/lgs_evt.cc > +++ b/osaf/services/saf/logsv/lgs/lgs_evt.cc > @@ -16,7 +16,6 @@ > */ > > #include <stdlib.h> > -#include "immutil.h" > #include "osaf_time.h" > #include "saf_error.h" > > @@ -30,8 +29,6 @@ > ( (ver->releaseCode == LOG_RELEASE_CODE) && \ > (ver->majorVersion == LOG_MAJOR_VERSION || ver->minorVersion == > LOG_MINOR_VERSION)) > > -extern struct ImmutilWrapperProfile immutilWrapperProfile; > - > static uint32_t process_api_evt(lgsv_lgs_evt_t *evt); > static uint32_t proc_lga_updn_mds_msg(lgsv_lgs_evt_t *evt); > static uint32_t proc_mds_quiesced_ack_msg(lgsv_lgs_evt_t *evt); > diff --git a/osaf/services/saf/logsv/lgs/lgs_imm.cc > b/osaf/services/saf/logsv/lgs/lgs_imm.cc > --- a/osaf/services/saf/logsv/lgs/lgs_imm.cc > +++ b/osaf/services/saf/logsv/lgs/lgs_imm.cc > @@ -82,8 +82,6 @@ static const SaImmOiImplementerNameT imp > static const SaImmClassNameT logConfig_str = > const_cast<SaImmClassNameT>("OpenSafLogConfig"); > static const SaImmClassNameT streamConfig_str = > const_cast<SaImmClassNameT>("SaLogStreamConfig"); > > -extern struct ImmutilWrapperProfile immutilWrapperProfile; > - > /* FUNCTIONS > * --------- > */ > @@ -375,6 +373,7 @@ static void adminOperationCallback(SaImm > SaUint32T severityFilter; > const SaImmAdminOperationParamsT_2 *param = params[0]; > log_stream_t *stream; > + SaAisErrorT ais_rc = SA_AIS_OK; > > TRACE_ENTER2("%s", objectName->value); > > @@ -394,8 +393,12 @@ static void adminOperationCallback(SaImm > SaImmClassNameT className = > immutil_get_className(objectName); > > if (!strcmp(className, "SaLogStreamConfig")) { > - > (void)immutil_saImmOiAdminOperationResult(immOiHandle, > + ais_rc = > immutil_saImmOiAdminOperationResult(immOiHandle, > > invocation, SA_AIS_ERR_NOT_SUPPORTED); > + if (ais_rc != SA_AIS_OK) { > + > LOG_ER("immutil_saImmOiAdminOperationResult failed %s", > saf_error(ais_rc)); > + osaf_abort(0); > + } > goto done; > } > > @@ -433,18 +436,35 @@ static void adminOperationCallback(SaImm > } > > if (severityFilter == stream->severityFilter) { > - > (void)immutil_saImmOiAdminOperationResult(immOiHandle, > invocation, SA_AIS_ERR_NO_OP); > + ais_rc = > immutil_saImmOiAdminOperationResult(immOiHandle, invocation, > SA_AIS_ERR_NO_OP); > + if (ais_rc != SA_AIS_OK) { > + > LOG_ER("immutil_saImmOiAdminOperationResult failed %s", > saf_error(ais_rc)); > + osaf_abort(0); > + } > + > goto done; > } > > TRACE("Changing severity for stream %s to %u", > stream->name, severityFilter); > stream->severityFilter = severityFilter; > > - (void)immutil_update_one_rattr(immOiHandle, > reinterpret_cast<const char *>(objectName->value), > - > const_cast<SaImmAttrNameT>("saLogStreamSeverityFilter"), > SA_IMM_ATTR_SAUINT32T, > - &stream->severityFilter); > - > - > (void)immutil_saImmOiAdminOperationResult(immOiHandle, > invocation, SA_AIS_OK); > + ais_rc = immutil_update_one_rattr( > + immOiHandle, > + reinterpret_cast<const char > *>(objectName->value), > + > const_cast<SaImmAttrNameT>("saLogStreamSeverityFilter"), > + SA_IMM_ATTR_SAUINT32T, > + &stream->severityFilter); > + if (ais_rc != SA_AIS_OK) { > + > LOG_ER("immutil_update_one_rattr failed %s", > saf_error(ais_rc)); > + osaf_abort(0); > + } > + > + ais_rc = > immutil_saImmOiAdminOperationResult(immOiHandle, invocation, > SA_AIS_OK); > + if (ais_rc != SA_AIS_OK) { > + > LOG_ER("immutil_saImmOiAdminOperationResult failed %s", > saf_error(ais_rc)); > + osaf_abort(0); > + } > + > > /* Checkpoint to standby LOG server */ > ckpt_stream_config(stream); > @@ -924,9 +944,6 @@ static lgs_stream_defval_t *get_SaLogStr > * We are only interested in > saLogStreamMaxLogFileSize and > * saLogStreamFixedLogRecordSize > */ > - int iu_setting = > immutilWrapperProfile.errorsAreFatal; > - immutilWrapperProfile.errorsAreFatal = 0; > - > rc = immutil_saImmOmInitialize(&om_handle, > NULL, &immVersion); > if (rc != SA_AIS_OK) { > > TRACE("immutil_saImmOmInitialize fail rc=%d", rc); > @@ -973,8 +990,6 @@ static lgs_stream_defval_t *get_SaLogStr > if (rc != SA_AIS_OK) { > > TRACE("immutil_saImmOmFinalize fail rc=%d", rc); > } > - > - immutilWrapperProfile.errorsAreFatal = > iu_setting; > } else { > TRACE("Defaults are already fetched"); > TRACE("saLogStreamMaxLogFileSize=%lld", > @@ -2195,9 +2210,13 @@ static SaAisErrorT stream_create_and_con > } > > /* Update creation timestamp */ > - (void) immutil_update_one_rattr(lgs_cb->immOiHandle, > reinterpret_cast<const char *>(objectName.value), > + rc = immutil_update_one_rattr(lgs_cb->immOiHandle, > reinterpret_cast<const char *>(objectName.value), > > const_cast<SaImmAttrNameT>("saLogStreamCreationTimesta > mp"), SA_IMM_ATTR_SATIMET, > &(*stream)- > >creationTimeStamp); > + if (rc != SA_AIS_OK) { > + LOG_ER("immutil_update_one_rattr failed %s", > saf_error(rc)); > + osaf_abort(0); > + } > > done: > TRACE_LEAVE(); > @@ -2475,13 +2494,14 @@ static SaAisErrorT rtAttrUpdateCallback( > > while ((attributeName = attributeNames[i++]) > != NULL) { > TRACE("Attribute %s", > attributeName); > + rc = SA_AIS_OK; > if (!strcmp(attributeName, > "saLogStreamNumOpeners")) { > - > (void)immutil_update_one_rattr(immOiHandle, > + rc = > immutil_update_one_rattr(immOiHandle, > (char > *)objectName->value, > > attributeName, SA_IMM_ATTR_SAUINT32T, > > &stream->numOpeners); > } else if (!strcmp(attributeName, > "logStreamDiscardedCounter")) { > - (void) > immutil_update_one_rattr(immOiHandle, > + rc = > immutil_update_one_rattr(immOiHandle, > (char > *) objectName->value, > > attributeName, SA_IMM_ATTR_SAUINT64T, > > &stream->filtered); > @@ -2490,6 +2510,12 @@ static SaAisErrorT rtAttrUpdateCallback( > > __FUNCTION__, attributeName); > goto done; > } > + > + if (rc != SA_AIS_OK) { > + > LOG_ER("immutil_update_one_rattr (%s) failed %s", > + attributeName, > saf_error(rc)); > + osaf_abort(0); > + } > } > } > > @@ -2556,9 +2582,11 @@ static SaAisErrorT stream_create_and_con > stream->streamType = > STREAM_TYPE_APPLICATION; > > /* Get all attributes of the object */ > - if (immutil_saImmOmAccessorGet_2(accessorHandle, > &objectName, > - attribute_names, &attributes) != > SA_AIS_OK) { > - LOG_ER("Configuration for %s not found", > objectName.value); > + if ((rc = immutil_saImmOmAccessorGet_2( > + accessorHandle, > + &objectName, > + attribute_names, &attributes)) != > SA_AIS_OK) { > + LOG_ER("Configuration for %s not found: %s", > objectName.value, saf_error(rc)); > rc = SA_AIS_ERR_NOT_EXIST; > goto done; > } > @@ -2679,7 +2707,6 @@ SaAisErrorT lgs_imm_init_configStreams(l > SaImmSearchParametersT_2 objectSearch; > SaImmAttrValuesT_2 **attributes; > int streamId = 0; > - int errorsAreFatal; > SaNameT objectName; > SaNameT root_name; > > @@ -2689,8 +2716,17 @@ SaAisErrorT lgs_imm_init_configStreams(l > > TRACE_ENTER(); > > - (void)immutil_saImmOmInitialize(&omHandle, NULL, > &immVersion); > - (void)immutil_saImmOmAccessorInitialize(omHandle, > &accessorHandle); > + om_rc = immutil_saImmOmInitialize(&omHandle, NULL, > &immVersion); > + if (om_rc != SA_AIS_OK) { > + LOG_ER("immutil_saImmOmInitialize failed %s", > saf_error(om_rc)); > + osaf_abort(0); > + } > + > + om_rc = immutil_saImmOmAccessorInitialize(omHandle, > &accessorHandle); > + if (om_rc != SA_AIS_OK) { > + LOG_ER("immutil_saImmOmAccessorInitialize > failed %s", saf_error(om_rc)); > + osaf_abort(0); > + } > > /* Search for all objects of class "SaLogStreamConfig" */ > objectSearch.searchOneAttr.attrName = > const_cast<SaImmAttrNameT>("safLgStrCfg"); > @@ -2723,11 +2759,11 @@ SaAisErrorT lgs_imm_init_configStreams(l > * without returning any error. A new attempt to create the > files will > * be done when trying to write a log record to the stream. > */ > - immutilWrapperProfile.nTries = 250; /* After loading,allow > missed sync of large data to complete */ > - > - (void)immutil_saImmOiClassImplementerSet(cb- > >immOiHandle, "SaLogStreamConfig"); > - > - immutilWrapperProfile.nTries = 20; /* Reset retry time to > more normal value. */ > + ais_rc = immutil_saImmOiClassImplementerSet(cb- > >immOiHandle, "SaLogStreamConfig"); > + if (ais_rc != SA_AIS_OK) { > + > LOG_ER("immutil_saImmOiClassImplementerSet failed %s", > saf_error(ais_rc)); > + osaf_abort(0); > + } > > stream = log_stream_getnext_by_name(NULL); > while (stream != NULL) { > @@ -2747,19 +2783,21 @@ SaAisErrorT lgs_imm_init_configStreams(l > stream->creationTimeStamp = > lgs_get_SaTime(); > } > > - (void)immutil_update_one_rattr( > + ais_rc = immutil_update_one_rattr( > cb->immOiHandle, stream- > >name, > > const_cast<SaImmAttrNameT>("saLogStreamCreationTimesta > mp"), > SA_IMM_ATTR_SATIMET, > &stream->creationTimeStamp); > + if (ais_rc != SA_AIS_OK) { > + > LOG_ER("immutil_update_one_rattr failed %s", > saf_error(ais_rc)); > + osaf_abort(0); > + } > > stream = > log_stream_getnext_by_name(stream->name); > } > > done: > /* Do not abort if error when finalizing */ > - errorsAreFatal = immutilWrapperProfile.errorsAreFatal; > - immutilWrapperProfile.errorsAreFatal = 0; /* Disable immutil > abort */ > om_rc = immutil_saImmOmAccessorFinalize(accessorHandle); > if (om_rc != SA_AIS_OK) { > LOG_NO("%s > immutil_saImmOmAccessorFinalize() Fail %d",__FUNCTION__, om_rc); > @@ -2775,8 +2813,6 @@ SaAisErrorT lgs_imm_init_configStreams(l > LOG_NO("%s immutil_saImmOmFinalize() Fail > %d",__FUNCTION__, om_rc); > } > > - immutilWrapperProfile.errorsAreFatal = errorsAreFatal; /* > Enable again */ > - > TRACE_LEAVE(); > return ais_rc; > } > @@ -3050,18 +3086,6 @@ void lgs_search_stream_objects() > > TRACE_ENTER(); > > - /* Save immutil settings and reconfigure immutil > - */ > - struct ImmutilWrapperProfile tmp_immutilWrapperProfile; > - tmp_immutilWrapperProfile.errorsAreFatal = > immutilWrapperProfile.errorsAreFatal; > - tmp_immutilWrapperProfile.nTries = > immutilWrapperProfile.nTries; > - tmp_immutilWrapperProfile.retryInterval = > immutilWrapperProfile.retryInterval; > - > - immutilWrapperProfile.errorsAreFatal = 0; > - immutilWrapperProfile.nTries = 500; > - immutilWrapperProfile.retryInterval = 1000; > - > - > /* Intialize Om API > */ > ais_rc = immutil_saImmOmInitialize(&immOmHandle, NULL, > &immVersion); > @@ -3103,7 +3127,7 @@ void lgs_search_stream_objects() > > ais_rc = immutil_saImmOmSearchNext_2(immSearchHandle, > &object_name, &attributes); > if (ais_rc == SA_AIS_ERR_NOT_EXIST) { > - TRACE("\tNo objects found"); > + TRACE("\tNo objects found %s", > saf_error(ais_rc)); > } > > while (ais_rc == SA_AIS_OK) { > @@ -3142,10 +3166,6 @@ done_fin_Om: > } > > done: > - /* Restore immutil settings */ > - immutilWrapperProfile.errorsAreFatal = > tmp_immutilWrapperProfile.errorsAreFatal; > - immutilWrapperProfile.nTries = > tmp_immutilWrapperProfile.nTries; > - immutilWrapperProfile.retryInterval = > tmp_immutilWrapperProfile.retryInterval; > > TRACE_LEAVE(); > } > @@ -3160,16 +3180,6 @@ void lgs_delete_one_stream_object(char * > return; > } > > - /* Save immutil settings and reconfigure */ > - struct ImmutilWrapperProfile tmp_immutilWrapperProfile; > - tmp_immutilWrapperProfile.errorsAreFatal = > immutilWrapperProfile.errorsAreFatal; > - tmp_immutilWrapperProfile.nTries = > immutilWrapperProfile.nTries; > - tmp_immutilWrapperProfile.retryInterval = > immutilWrapperProfile.retryInterval; > - > - immutilWrapperProfile.errorsAreFatal = 0; > - immutilWrapperProfile.nTries = 500; > - immutilWrapperProfile.retryInterval = 1000; > - > /* Copy name to a SaNameT */ > (void) strncpy(reinterpret_cast<char *>(object_name.value), > name_str, SA_MAX_NAME_LENGTH); > @@ -3184,11 +3194,6 @@ void lgs_delete_one_stream_object(char * > LOG_WA("%s saImmOiRtObjectDelete for > \"%s\" FAILED %d", > __FUNCTION__, reinterpret_cast<char > *>(object_name.value), ais_rc); > } > - > - /* Restore immutil settings */ > - immutilWrapperProfile.errorsAreFatal = > tmp_immutilWrapperProfile.errorsAreFatal; > - immutilWrapperProfile.nTries = > tmp_immutilWrapperProfile.nTries; > - immutilWrapperProfile.retryInterval = > tmp_immutilWrapperProfile.retryInterval; > } > > /** > @@ -3210,16 +3215,6 @@ void lgs_cleanup_abandoned_streams() > return; > } > > - /* Save immutil settings and reconfigure */ > - struct ImmutilWrapperProfile tmp_immutilWrapperProfile; > - tmp_immutilWrapperProfile.errorsAreFatal = > immutilWrapperProfile.errorsAreFatal; > - tmp_immutilWrapperProfile.nTries = > immutilWrapperProfile.nTries; > - tmp_immutilWrapperProfile.retryInterval = > immutilWrapperProfile.retryInterval; > - > - immutilWrapperProfile.errorsAreFatal = 0; > - immutilWrapperProfile.nTries = 500; > - immutilWrapperProfile.retryInterval = 1000; > - > pos = log_rtobj_list_getnamepos(); > while (pos != -1) { > /* Get found name */ > @@ -3258,11 +3253,6 @@ void lgs_cleanup_abandoned_streams() > pos = log_rtobj_list_getnamepos(); > } > > - /* Restore immutil settings */ > - immutilWrapperProfile.errorsAreFatal = > tmp_immutilWrapperProfile.errorsAreFatal; > - immutilWrapperProfile.nTries = > tmp_immutilWrapperProfile.nTries; > - immutilWrapperProfile.retryInterval = > tmp_immutilWrapperProfile.retryInterval; > - > TRACE_LEAVE(); > } > > @@ -3297,17 +3287,6 @@ int lgs_get_streamobj_attr(SaImmAttrValu > TRACE_ENTER2("object_name_in \"%s\"", object_name_in); > > SaNameT object_name; > - > - /* Save immutil settings and reconfigure */ > - struct ImmutilWrapperProfile tmp_immutilWrapperProfile; > - tmp_immutilWrapperProfile.errorsAreFatal = > immutilWrapperProfile.errorsAreFatal; > - tmp_immutilWrapperProfile.nTries = > immutilWrapperProfile.nTries; > - tmp_immutilWrapperProfile.retryInterval = > immutilWrapperProfile.retryInterval; > - > - immutilWrapperProfile.errorsAreFatal = 0; > - immutilWrapperProfile.nTries = 500; > - immutilWrapperProfile.retryInterval = 1000; > - > if (object_name_in == NULL) { > TRACE("%s No object name given (NULL)", > __FUNCTION__); > rc = -1; > @@ -3357,11 +3336,6 @@ done_fin_Om: > } > > done: > - /* Restore immutil settings */ > - immutilWrapperProfile.errorsAreFatal = > tmp_immutilWrapperProfile.errorsAreFatal; > - immutilWrapperProfile.nTries = > tmp_immutilWrapperProfile.nTries; > - immutilWrapperProfile.retryInterval = > tmp_immutilWrapperProfile.retryInterval; > - > TRACE_LEAVE(); > return rc; > } > @@ -3379,16 +3353,6 @@ int lgs_free_streamobj_attr(SaImmHandleT > > TRACE_ENTER(); > > - /* Save immutil settings and reconfigure */ > - struct ImmutilWrapperProfile tmp_immutilWrapperProfile; > - tmp_immutilWrapperProfile.errorsAreFatal = > immutilWrapperProfile.errorsAreFatal; > - tmp_immutilWrapperProfile.nTries = > immutilWrapperProfile.nTries; > - tmp_immutilWrapperProfile.retryInterval = > immutilWrapperProfile.retryInterval; > - > - immutilWrapperProfile.errorsAreFatal = 0; > - immutilWrapperProfile.nTries = 500; > - immutilWrapperProfile.retryInterval = 1000; > - > ais_rc = immutil_saImmOmFinalize(immOmHandle); > if (ais_rc != SA_AIS_OK) { > TRACE("%s\t saImmOmFinalize Fail '%s'", > @@ -3396,11 +3360,6 @@ int lgs_free_streamobj_attr(SaImmHandleT > rc = -1; > } > > - /* Restore immutil settings */ > - immutilWrapperProfile.errorsAreFatal = > tmp_immutilWrapperProfile.errorsAreFatal; > - immutilWrapperProfile.nTries = > tmp_immutilWrapperProfile.nTries; > - immutilWrapperProfile.retryInterval = > tmp_immutilWrapperProfile.retryInterval; > - > TRACE_LEAVE(); > return rc; > } > @@ -3441,16 +3400,6 @@ SaUint32T *lgs_get_scAbsenceAllowed_attr > */ > *attr_val = 0; > > - /* Save immutil settings and reconfigure */ > - struct ImmutilWrapperProfile tmp_immutilWrapperProfile; > - tmp_immutilWrapperProfile.errorsAreFatal = > immutilWrapperProfile.errorsAreFatal; > - tmp_immutilWrapperProfile.nTries = > immutilWrapperProfile.nTries; > - tmp_immutilWrapperProfile.retryInterval = > immutilWrapperProfile.retryInterval; > - > - immutilWrapperProfile.errorsAreFatal = 0; > - immutilWrapperProfile.nTries = 500; > - immutilWrapperProfile.retryInterval = 1000; > - > /* Initialize Om API > */ > ais_rc = immutil_saImmOmInitialize(&immOmHandle, NULL, > &immVersion); > @@ -3498,11 +3447,6 @@ done_fin_Om: > } > > done: > - /* Restore immutil settings */ > - immutilWrapperProfile.errorsAreFatal = > tmp_immutilWrapperProfile.errorsAreFatal; > - immutilWrapperProfile.nTries = > tmp_immutilWrapperProfile.nTries; > - immutilWrapperProfile.retryInterval = > tmp_immutilWrapperProfile.retryInterval; > - > TRACE_LEAVE(); > return rc_attr_val; > } > diff --git a/osaf/services/saf/logsv/lgs/lgs_imm_gcfg.cc > b/osaf/services/saf/logsv/lgs/lgs_imm_gcfg.cc > --- a/osaf/services/saf/logsv/lgs/lgs_imm_gcfg.cc > +++ b/osaf/services/saf/logsv/lgs/lgs_imm_gcfg.cc > @@ -117,8 +117,6 @@ typedef enum { > > static th_state_t th_state = TH_NOT_STARTED; > > -extern struct ImmutilWrapperProfile immutilWrapperProfile; > - > > /********************************************************** > ******************** > * Outside applier thread > > ********************************************************** > ********************/ > @@ -609,11 +607,6 @@ static int read_network_name() > /* > * Initialize an IMM object manager > */ > - // Wait up to 500ms > - immutilWrapperProfile.errorsAreFatal = 0; > - immutilWrapperProfile.nTries = 500; > - immutilWrapperProfile.retryInterval = 1000; > - > ais_rc = immutil_saImmOmInitialize(&om_handle, NULL, > &immVersion); > if (ais_rc != SA_AIS_OK) { > TRACE("immutil_saImmOmInitialize FAIL %s", > saf_error(ais_rc)); > @@ -735,11 +728,6 @@ static int applier_init(SaImmOiHandleT * > goto done; > } > > - // Wait up to 500ms > - immutilWrapperProfile.errorsAreFatal = 0; > - immutilWrapperProfile.nTries = 500; > - immutilWrapperProfile.retryInterval = 1000; > - > /* Initialize OI for applier and get OI handle */ > ais_rc = immutil_saImmOiInitialize_2(imm_appl_hdl, > &callbacks, &immVersion); > if (ais_rc != SA_AIS_OK) { > @@ -804,10 +792,6 @@ static int applier_set_name_class(SaImmO > } > > /* Become applier */ > - immutilWrapperProfile.errorsAreFatal = 0; > - immutilWrapperProfile.nTries = 500; > - immutilWrapperProfile.retryInterval = 1000; > - > ais_rc = immutil_saImmOiImplementerSet(imm_appl_hdl, > applier_name); > if (ais_rc != SA_AIS_OK) { > LOG_WA("immutil_saImmOiImplementerSet > Failed %s", saf_error(ais_rc)); > @@ -859,11 +843,6 @@ static void applier_finalize(SaImmOiHand > if (imm_appl_hdl != 0) { > /* We have a handle to finalize */ > TRACE("saImmOiFinalize"); > - > - immutilWrapperProfile.errorsAreFatal = 0; > - immutilWrapperProfile.nTries = 500; > - immutilWrapperProfile.retryInterval = 1000; > - > ais_rc = > immutil_saImmOiFinalize(imm_appl_hdl); > if (ais_rc != SA_AIS_OK) { > TRACE("immutil_saImmOiFinalize > Failed %s", saf_error(ais_rc)); > diff --git a/osaf/services/saf/logsv/lgs/lgs_main.cc > b/osaf/services/saf/logsv/lgs/lgs_main.cc > --- a/osaf/services/saf/logsv/lgs/lgs_main.cc > +++ b/osaf/services/saf/logsv/lgs/lgs_main.cc > @@ -37,6 +37,7 @@ > #include "lgs_file.h" > #include "osaf_utility.h" > #include "lgs_recov.h" > +#include "immutil.h" > > /* > ========================================================== > ============== > * DEFINITIONS > @@ -89,6 +90,8 @@ uint32_t mbox_low[NCS_IPC_PRIORITY_MAX]; > */ > pthread_mutex_t lgs_mbox_init_mutex = PTHREAD_MUTEX_INITIALIZER; > > +extern struct ImmutilWrapperProfile immutilWrapperProfile; > + > static struct pollfd fds[FD_NUM]; > static nfds_t nfds = FD_NUM; > static NCS_SEL_OBJ usr1_sel_obj; > @@ -274,6 +277,18 @@ static uint32_t log_initialize(void) > > TRACE_ENTER(); > > + /** > + * Setup immutils profile once and for all. > + * This profile says immutil_ API will be blocked > + * up to 0.5s and no terminated when failed. > + * > + * Use IMM API directly if wants to change above immutil_ > behavior. > + * Otherwise, there is possibility of race condition. > + */ > + immutilWrapperProfile.errorsAreFatal = 0; /* No reboot > when fail */ > + immutilWrapperProfile.nTries = 500; /* Times */ > + immutilWrapperProfile.retryInterval = 1000; /* ms */ > + > /* Determine how this process was started, by NID or AMF */ > if (getenv("SA_AMF_COMPONENT_NAME") == NULL) > lgs_cb->nid_started = true; > diff --git a/osaf/services/saf/logsv/lgs/lgs_util.cc > b/osaf/services/saf/logsv/lgs/lgs_util.cc > --- a/osaf/services/saf/logsv/lgs/lgs_util.cc > +++ b/osaf/services/saf/logsv/lgs/lgs_util.cc > @@ -32,7 +32,6 @@ > #include <grp.h> > #include <osaf_time.h> > > -#include "immutil.h" > #include "lgs.h" > #include "lgs_file.h" > #include "lgs_filehdl.h" ------------------------------------------------------------------------------ Mobile security can be enabling, not merely restricting. Employees who bring their own devices (BYOD) to work are irked by the imposition of MDM restrictions. Mobile Device Manager Plus allows you to control only the apps on BYO-devices by containerizing them, leaving personal data untouched! https://ad.doubleclick.net/ddm/clk/304595813;131938128;j _______________________________________________ Opensaf-devel mailing list Opensaf-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/opensaf-devel