Skip to content

Commit e1942e4

Browse files
Remove the unused mutex in shm_monitor
Signed-off-by: Sumanth Nirmal <sumanth.724@gmail.com>
1 parent 2763af6 commit e1942e4

2 files changed

Lines changed: 5 additions & 10 deletions

File tree

src/core/ddsc/src/shm__monitor.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,7 @@ enum shm_monitor_states {
3939
/// @brief abstraction for monitoring the shared memory communication with an internal
4040
/// thread responsible for reacting on received data via shared memory
4141
struct shm_monitor {
42-
ddsrt_mutex_t m_lock;
4342
iox_listener_t m_listener;
44-
4543
//use this if we wait but want to wake up for some reason e.g. terminate
4644
iox_user_trigger_t m_wakeup_trigger;
4745
uint32_t m_state;

src/core/ddsc/src/shm_monitor.c

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,11 @@ static void shm_subscriber_callback(iox_sub_t subscriber, void * context_data);
3232

3333
void shm_monitor_init(shm_monitor_t* monitor)
3434
{
35-
ddsrt_mutex_init(&monitor->m_lock);
36-
37-
// storage is ignored internally now but we cannot pass a nullptr
38-
monitor->m_listener = iox_listener_init(&(iox_listener_storage_t){0});
39-
monitor->m_wakeup_trigger = iox_user_trigger_init(&(iox_user_trigger_storage_t){0});
35+
// storage is ignored internally now but we cannot pass a nullptr
36+
iox_listener_storage_t s;
37+
monitor->m_listener = iox_listener_init(&s);
38+
iox_user_trigger_storage_t t;
39+
monitor->m_wakeup_trigger = iox_user_trigger_init(&t);
4040

4141
monitor->m_state = SHM_MONITOR_RUNNING;
4242
}
@@ -51,7 +51,6 @@ void shm_monitor_destroy(shm_monitor_t* monitor)
5151

5252
iox_listener_deinit(monitor->m_listener);
5353
iox_user_trigger_deinit(monitor->m_wakeup_trigger);
54-
ddsrt_mutex_destroy(&monitor->m_lock);
5554
}
5655

5756
dds_return_t shm_monitor_wake_and_disable(shm_monitor_t* monitor)
@@ -98,14 +97,12 @@ dds_return_t shm_monitor_attach_reader(shm_monitor_t* monitor, struct dds_reader
9897

9998
dds_return_t shm_monitor_detach_reader(shm_monitor_t* monitor, struct dds_reader* reader)
10099
{
101-
ddsrt_mutex_lock(&monitor->m_lock);
102100
// if the reader is attached
103101
if (reader->m_iox_sub_context.monitor != NULL && reader->m_iox_sub_context.parent_reader != NULL) {
104102
iox_listener_detach_subscriber_event(monitor->m_listener, reader->m_iox_sub, SubscriberEvent_DATA_RECEIVED);
105103
reader->m_iox_sub_context.monitor = NULL;
106104
reader->m_iox_sub_context.parent_reader = NULL;
107105
}
108-
ddsrt_mutex_unlock(&monitor->m_lock);
109106
return DDS_RETCODE_OK;
110107
}
111108

0 commit comments

Comments
 (0)