To avoid lots of code changed, I intent to create an macro which is same as
`immutil_` API, but thread safe. Something likes:
``` C
/**
* @P ImmutilWrapperProfile_t input
* @F IMM API
* ... Arguments to IMM API
*
* Caller can use AIS_RET to get the return value
*/
#define IMMUTIL_F(P, F, ...) SaAisErrorT AIS_RET = F(__VA_ARGS__);
\
unsigned int nTries_m = 1; \
while (AIS_RET == SA_AIS_ERR_TRY_AGAIN \
&& nTries_m < P.nTries) { \
usleep(P.retryInterval * 1000); \
AIS_RET = F(__VA_ARGS__); \
nTries_m++; \
} \
if (AIS_RET != SA_AIS_OK && P.errorsAreFatal) \
logError("%s FAILED, rc = %d", #F, (int) AIS_RET);
```
And here is the sample to use the macro:
``` C
ImmutilWrapperProfile_t profile;
profile.errorsAreFatal = 0;
profile.nTries = 500;
profile.retryInterval = 1000;
IMMUTIL_F(profile, saImmOmInitialize, &om_handle, NULL, &immVersion);
if (AIS_RET != SA_AIS_OK) {
TRACE("immutil_saImmOmInitialize FAIL %s", saf_error(AIS_RET));
rc = -1;
goto done;
}
```
The above code is equivalent to following code:
``` C
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));
rc = -1;
goto done;
}
```
Any comment on this approach or any suggestion for better solution?
---
** [tickets:#1807] log: global immutilWrapperProfile is not thread safe**
**Status:** accepted
**Milestone:** 5.0.1
**Created:** Thu May 05, 2016 03:57 AM UTC by Vu Minh Nguyen
**Last Updated:** Thu May 05, 2016 04:01 AM UTC
**Owner:** Vu Minh Nguyen
There are some threads running which use the common global
`immutilWrapperProfile` variable.
1) imm_impl_init_thread
2) applier_thread
3) main thread
so, using `immutil` API is not thread safe anymore to log service.
---
Sent from sourceforge.net because [email protected] is
subscribed to https://sourceforge.net/p/opensaf/tickets/
To unsubscribe from further messages, a project admin can change settings at
https://sourceforge.net/p/opensaf/admin/tickets/options. Or, if this is a
mailing list, you can unsubscribe from the mailing list.------------------------------------------------------------------------------
Find and fix application performance issues faster with Applications Manager
Applications Manager provides deep performance insights into multiple tiers of
your business applications. It resolves application problems quickly and
reduces your MTTR. Get your free trial!
https://ad.doubleclick.net/ddm/clk/302982198;130105516;z
_______________________________________________
Opensaf-tickets mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/opensaf-tickets