message: do not erase locks from held map that we have recursively locked them and have more than 0 remaining locked
diff: @@ -17,8 +17,6 @@ void _remove_lock_critical_exit(void *cs)
  return;
  }
  uint64_t tid = getTid();
  - OwnershipType ownership = OwnershipType::SHARED;
  - bool fTry = false;
  auto it = lockdata.locksheldbythread.find(tid);
  if (it == lockdata.locksheldbythread.end())
  {
  @@ -29,10 +27,23 @@ void _remove_lock_critical_exit(void *cs)
  LOGA("got %s but was not expecting it\n", it->second.back().second.ToString().c_str());
  throw std::logic_error("unlock order inconsistant with lock order");
  }
  - ownership = it->second.back().second.GetExclusive();
  - fTry = it->second.back().second.GetTry();
  + LockType type = it->second.back().second.GetLockType();
  + OwnershipType ownership = it->second.back().second.GetExclusive();
  + bool fTry = it->second.back().second.GetTry();
  // assuming we unlock in the reverse order of locks, we can simply pop back
  it->second.pop_back();
  + // if we have no more locks on this critical section...
  + if (type != LockType::SHARED_MUTEX)
  + {
  + for (auto entry : it->second)
  + {
  + if(entry.first == cs)
  + {
  + // we have another lock on this critical section
  + return;
  + }
  + }
  + }
  // remove from the other maps
  if (ownership == OwnershipType::EXCLUSIVE)
  {
  