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 5129757 commit f1399c4
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions messaging/msgq.cc
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ SharedMemory::SharedMemory(const std::string &name, size_t size) :shm_name(name)
shm_ptr = mmap(0, shm_size, PROT_READ | PROT_WRITE, MAP_SHARED, shm_fd, 0);
assert(shm_ptr != MAP_FAILED);

// sem_t *sem = sem_open(SEMAPHORE_NAME, O_CREAT, 0644, 1);
// assert(sem != SEM_FAILED);
// sem_wait(sem); // Lock semaphore
sem_t *sem = sem_open(SEMAPHORE_NAME, O_CREAT, 0644, 1);
assert(sem != SEM_FAILED);
sem_wait(sem); // Lock semaphore
header = (SharedMemoryHeader *)shm_ptr;

/*
Expand Down Expand Up @@ -71,8 +71,8 @@ SharedMemory::SharedMemory(const std::string &name, size_t size) :shm_name(name)
} else {
printf("initialized\n");
}
// sem_post(sem); // Unlock semaphore
// sem_close(sem);
sem_post(sem); // Unlock semaphore
sem_close(sem);
}

SharedMemory::~SharedMemory() {
Expand Down

0 comments on commit f1399c4

Please sign in to comment.