File tree Expand file tree Collapse file tree 2 files changed +19
-4
lines changed
Expand file tree Collapse file tree 2 files changed +19
-4
lines changed Original file line number Diff line number Diff line change @@ -111,6 +111,8 @@ class ShmManager
111111 bool started_;
112112 boost::interprocess::interprocess_mutex shm_sub_mutex_;
113113 std::map<std::string, bool > shm_skip_first_msg_;
114+ boost::mutex shm_map_mutex_;
115+ boost::mutex shm_first_msg_map_mutex_;
114116};
115117
116118}
Original file line number Diff line number Diff line change @@ -183,9 +183,13 @@ void ShmManager::threadFunc()
183183 item.datatype = sharedmem_util.get_datatype (segment);
184184 item.message_definition = sharedmem_util.get_msg_def (segment);
185185
186+ boost::mutex::scoped_lock lock (shm_map_mutex_);
187+
186188 shm_map_[topic] = item;
187189 }
188190
191+ boost::mutex::scoped_lock lock (shm_first_msg_map_mutex_);
192+
189193 if (shm_skip_first_msg_.find (topic) == shm_skip_first_msg_.end ())
190194 {
191195 if (segment == NULL )
@@ -242,12 +246,21 @@ void ShmManager::threadFunc()
242246 if (read_index == sharedmem_transport::ROS_SHM_SEGMENT_WROTE_NUM ||
243247 shm_map_[topic].shm_sub_ptr ->get_publisher_links ().size () == 0 )
244248 {
245- if (shm_map_[topic].addr_sub )
246249 {
247- delete [] (shm_map_[topic].addr_sub );
250+ boost::mutex::scoped_lock lock (shm_map_mutex_);
251+
252+ if (shm_map_[topic].addr_sub )
253+ {
254+ delete [] (shm_map_[topic].addr_sub );
255+ }
256+ shm_map_.erase (topic);
257+ }
258+
259+ {
260+ boost::mutex::scoped_lock lock (shm_first_msg_map_mutex_);
261+ shm_skip_first_msg_.erase (topic);
248262 }
249- shm_map_.erase (topic);
250- shm_skip_first_msg_.erase (topic);
263+
251264 is_new_msg = false ;
252265 exit = true ;
253266 }
You can’t perform that action at this time.
0 commit comments