Menu

#1807 log: global immutilWrapperProfile is not thread safe

5.0.1
fixed
nobody
None
defect
log
-
5.0RC2
major
2016-05-18
2016-05-05
No

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.

Related

Tickets: #1807
Wiki: ChangeLog-5.0.1

Discussion

  • Vu Minh Nguyen

    Vu Minh Nguyen - 2016-05-05
    • status: unassigned --> accepted
    • assigned_to: Vu Minh Nguyen
     
  • Vu Minh Nguyen

    Vu Minh Nguyen - 2016-05-06

    To avoid lots of code changed, I intent to create an macro which is same as immutil_ API, but thread safe. Something likes:

        /**
         * @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:

        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:

        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?

     

    Last edit: Vu Minh Nguyen 2016-05-06
  • Vu Minh Nguyen

    Vu Minh Nguyen - 2016-05-11
    • status: accepted --> review
     
  • elunlen

    elunlen - 2016-05-18
    • status: review --> fixed
    • assigned_to: Vu Minh Nguyen --> nobody
     
  • elunlen

    elunlen - 2016-05-18

    changeset: 7647:2a3845194df2
    tag: tip
    parent: 7644:c893131ce311
    user: Vu Minh Nguyen vu.m.nguyen@dektech.com.au
    date: Wed May 18 13:13:19 2016 +0200
    summary: log: make using immutilWrapperProfile thread safe [#1807]

    ver: 2a3845194df27447360ceb2653b761f8a308d12f

    changeset: 7646:4742b04046da
    branch: opensaf-5.0.x
    user: Vu Minh Nguyen vu.m.nguyen@dektech.com.au
    date: Wed May 18 13:13:19 2016 +0200
    summary: log: make using immutilWrapperProfile thread safe [#1807]

    ver: 4742b04046da5ac37321208fe789141e6a92b361

     

    Related

    Tickets: #1807


Log in to post a comment.