Uploaded image for project: 'Traffic Server'
  1. Traffic Server
  2. TS-1678

Unnecessary lock releasing in RecRegisterStat()

    XMLWordPrintableJSON

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 3.3.1
    • Component/s: Metrics
    • Labels:
      None

      Description

      It seems that lock releasing in the following code is unnecessary and dangerous in some situation.

      //-------------------------------------------------------------------------
      // RecRegisterStat
      //-------------------------------------------------------------------------
      RecRecord *
      RecRegisterStat(RecT rec_type, const char *name, RecDataT data_type, RecData data_default, RecPersistT persist_type)
      {
        RecRecord *r = NULL;
      
        ink_rwlock_wrlock(&g_records_rwlock);
        if ((r = register_record(rec_type, name, data_type, data_default, false)) != NULL) {
          r->stat_meta.persist_type = persist_type;
          rec_mutex_release(&(r->lock));  //dangerous!!
        } else {
          ink_debug_assert(!"Can't register record!");
        }
        ink_rwlock_unlock(&g_records_rwlock);
      
        return r;
      }
      
      

        Attachments

          Activity

            People

            • Assignee:
              jamespeach James Peach
              Reporter:
              yunkai Yunkai Zhang
            • Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: