Skip to content

Commit

Permalink
dd
Browse files Browse the repository at this point in the history
  • Loading branch information
deanlee committed May 29, 2024
1 parent f454f7e commit e68f321
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion messaging/msgq.cc
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,22 @@ SharedMemory::SharedMemory(const std::string &name, size_t size) :shm_name(name)
assert(sem != SEM_FAILED);
sem_wait(sem); // Lock semaphore
header = (SharedMemoryHeader *)shm_ptr;

/*
bool is_mutex_initialized() {
int result = pthread_mutex_trylock(&mutex);
if (result == 0) {
pthread_mutex_unlock(&mutex);
return true;
} else if (result == EBUSY) {
return true;
} else if (result == EINVAL) {
return false;
}
return false;
}
*/

if (!header->initialized) {
pthread_mutexattr_t mutex_attr;
pthread_condattr_t cond_attr;
Expand Down Expand Up @@ -448,7 +464,6 @@ int msgq_poll(msgq_pollitem_t * items, size_t nitems, int timeout){
break;
}
}

return num;
}

Expand Down

0 comments on commit e68f321

Please sign in to comment.