Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

set call_finished_ with true for each call inside callFinished #2074

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions clients/roscpp/src/libros/service_server_link.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,7 @@ void ServiceServerLink::callFinished()

current_call_->finished_ = true;
current_call_->finished_condition_.notify_all();
current_call_->call_finished_ = true;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it looks reasonable to change call_finished_ into true once current call in the queue is finished.

but is this supposed to be moved from caller thread? adding call_finished_ = true here means, it should check if call_finished_ is true on caller thread instead.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

but is this supposed to be moved from caller thread?

It should keep here. There are some cases, such as,

TEST(SrvCall, callSrvWithWrongType)
{
test_roscpp::BadTestStringString::Request req;
test_roscpp::BadTestStringString::Response res;
ASSERT_TRUE(ros::service::waitForService("service_adv"));
for ( int i = 0; i < 4; ++i )
{
bool call_result = ros::service::call("service_adv", req, res);
ASSERT_FALSE(call_result);
}
}

in this case, ServiceServerLink::callFinished will not be called, and then if ServiceServerLink exit,

ServiceServerLink::~ServiceServerLink -> ... -> ServiceServerLink::cancelCall

{
boost::mutex::scoped_lock lock(local->finished_mutex_);
local->finished_ = true;
local->finished_condition_.notify_all();
}
if (boost::this_thread::get_id() != info->caller_thread_id_)
{
while (!local->call_finished_)
{
boost::this_thread::yield();
}
}

stuck in while (!local->call_finished_) if we remove

info->call_finished_ = true;

adding call_finished_ = true here means, it should check if call_finished_ is true

Okay


saved_call = current_call_;
current_call_ = CallInfoPtr();
Expand Down