You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@trafficserver.apache.org by "Yunkai Zhang (JIRA)" <ji...@apache.org> on 2013/01/31 10:43:12 UTC

[jira] [Created] (TS-1678) Unnecessary lock releasing in RecRegisterStat()

Yunkai Zhang created TS-1678:
--------------------------------

             Summary: Unnecessary lock releasing in RecRegisterStat()
                 Key: TS-1678
                 URL: https://issues.apache.org/jira/browse/TS-1678
             Project: Traffic Server
          Issue Type: Improvement
          Components: Stats
            Reporter: Yunkai Zhang


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

{code}
//-------------------------------------------------------------------------
// 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;
}

{code}

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira