Skip to content

Commit

Permalink
This could probably be a race condition, for ex: When we've create a …
Browse files Browse the repository at this point in the history
…subscriber in the API, and the subscriber has the data already available in the callback (Cause of existing publishers) the db entry for the particular topic would not be availalble, which in turn returns an SqliteException. This is cause write_->create_topic() call is where we add the db entry for a particular topic. And, this leads to crashing before any recording.

Locally I solved it by adding the db entry first, and if
create_subscription fails, remove the topic entry from the db and also
erase the subscription.

Signed-off-by: Sriram Raghunathan <rsriram7@visteon.com>
  • Loading branch information
Sriram Raghunathan committed May 20, 2019
1 parent c388d8e commit 458e6ef
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions rosbag2_transport/src/rosbag2_transport/recorder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,11 @@ void Recorder::subscribe_topics(

void Recorder::subscribe_topic(const rosbag2::TopicMetadata & topic)
{
if(writer_) {
writer_->create_topic(topic);
subscribed_topics_.insert(topic.name);
}

auto subscription = create_subscription(topic.name, topic.type);

if (subscription) {
Expand All @@ -117,6 +122,11 @@ void Recorder::subscribe_topic(const rosbag2::TopicMetadata & topic)
writer_->remove_topic(topic);
subscribed_topics_.erase(topic.name);
}
else {
writer_->remove_topic(topic);
subscribed_topics_.erase(topic.name);
}

}

std::shared_ptr<GenericSubscription>
Expand Down

0 comments on commit 458e6ef

Please sign in to comment.