ACE_Mutex никогда не вызывает pthread_mutex_destroy

В моем коде я использую ACE_Mutex из библиотеки ACE в системе (QNX), которая имеет pthreads. Теперь я испытываю проблему, которая кажется деструктором ACE_Mutex не звонит pthread_mutex_destroy, Это создает проблемы при инициализации последующего мьютекса в той же ячейке памяти, потому что pthread_mutex_init возвращается errno=16 (EBUSY).

Глядя на код ACE_Mutex::removeMutex.inl), Я вижу странный набор директив прекомпилятора:

ACE_INLINE int
ACE_Mutex::remove (void)
{
// ACE_TRACE ("ACE_Mutex::remove");
int result = 0;
#if defined (ACE_HAS_PTHREADS) || defined (ACE_HAS_STHREADS)
// In the case of a interprocess mutex, the owner is the first
// process that created the shared memory object. In this case, the
// lockname_ pointer will be non-zero (points to allocated memory
// for the name).  Owner or not, the memory needs to be unmapped
// from the process.  If we are the owner, the file used for
// shm_open needs to be deleted as well.
if (this->process_lock_)
{
if (this->removed_ == false)
{
this->removed_ = true;
// Only destroy the lock if we're the ones who initialized
// it.
if (!this->lockname_)
ACE_OS::munmap ((void *) this->process_lock_,
sizeof (ACE_mutex_t));
else
{
result = ACE_OS::mutex_destroy (this->process_lock_);
ACE_OS::munmap ((void *) this->process_lock_,
sizeof (ACE_mutex_t));
ACE_OS::shm_unlink (this->lockname_);
ACE_OS::free (
static_cast<void *> (
const_cast<ACE_TCHAR *> (this->lockname_)));
}
}
}
else
{
#else /* !ACE_HAS_PTHREADS && !ACE_HAS_STHREADS */
if (this->removed_ == false)
{
this->removed_ = true;
result = ACE_OS::mutex_destroy (&this->lock_);
}
#endif /* ACE_HAS_PTHREADS || ACE_HAS_STHREADS */
#if defined (ACE_HAS_PTHREADS) || defined (ACE_HAS_STHREADS)
}
#endif /* ACE_HAS_PTHREADS || ACE_HAS_STHREADS */
return result;
}

В частности, я не понимаю, почему звонок ACE_OS::mutex_destroy является условным и, следовательно, не вызывается, когда включены pthreads. Это эффективно делает remove метод с пустым телом для непроцессорных мьютексов. Может кто-нибудь объяснить обоснование этого куска кода?

1

Решение

Задача ещё не решена.

Другие решения

Других решений пока нет …

По вопросам рекламы ammmcru@yandex.ru
Adblock
detector