~ubuntu-branches/ubuntu/quantal/ceph/quantal

« back to all changes in this revision

Viewing changes to src/common/Mutex.h

  • Committer: Bazaar Package Importer
  • Author(s): Clint Byrum, Clint Byrum, Micah Gersten
  • Date: 2011-02-12 22:50:26 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20110212225026-yyyw4tk0msgql3ul
Tags: 0.24.2-0ubuntu1
[ Clint Byrum <clint@ubuntu.com> ]
* New upstream release. (LP: #658670, LP: #684011)
* debian/patches/fix-mkcephfs.patch: dropped (applied upstream)
* Removed .la files from libceph1-dev, libcrush1-dev and 
  librados1-dev (per Debian policy v3.9.1 10.2).
* debian/control: adding pkg-config as a build dependency
* debian/control: depend on libcrypto++-dev instead of libssl-dev
* debian/watch: added watch file

[ Micah Gersten <micahg@ubuntu.com> ]
* debian/control: add Homepage

Show diffs side-by-side

added added

removed removed

Lines of Context:
62
62
  Mutex(const char *n, bool r = false, bool ld=true, bool bt=false) :
63
63
    name(n), id(-1), recursive(r), lockdep(ld), backtrace(bt), nlock(0) {
64
64
    if (recursive) {
 
65
      // Mutexes of type PTHREAD_MUTEX_RECURSIVE do all the same checks as
 
66
      // mutexes of type PTHREAD_MUTEX_ERRORCHECK.
65
67
      pthread_mutexattr_t attr;
66
68
      pthread_mutexattr_init(&attr);
67
69
      pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE);
68
70
      pthread_mutex_init(&_m,&attr);
69
71
      pthread_mutexattr_destroy(&attr);
70
 
    } else {
 
72
      if (g_lockdep)
 
73
        _register();
 
74
    }
 
75
    else if (lockdep) {
 
76
      // If the mutex type is PTHREAD_MUTEX_ERRORCHECK, then error checking
 
77
      // shall be provided. If a thread attempts to relock a mutex that it
 
78
      // has already locked, an error shall be returned. If a thread
 
79
      // attempts to unlock a mutex that it has not locked or a mutex which
 
80
      // is unlocked, an error shall be returned.
 
81
      pthread_mutexattr_t attr;
 
82
      pthread_mutexattr_init(&attr);
 
83
      pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_ERRORCHECK);
 
84
      pthread_mutex_init(&_m, &attr);
 
85
      if (g_lockdep)
 
86
        _register();
 
87
    }
 
88
    else {
 
89
      // If the mutex type is PTHREAD_MUTEX_NORMAL, deadlock detection
 
90
      // shall not be provided. Attempting to relock the mutex causes
 
91
      // deadlock. If a thread attempts to unlock a mutex that  it  has not
 
92
      // locked or a mutex which is unlocked, undefined behavior results.
71
93
      pthread_mutex_init(&_m, NULL);
72
94
    }
73
 
    if (lockdep && g_lockdep) _register();
74
95
  }
75
96
  ~Mutex() {
76
97
    assert(nlock == 0);