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

Handle exception in uvc_sensor::acquire_power #7604

Merged
merged 4 commits into from
Oct 22, 2020
Merged
Changes from 1 commit
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
14 changes: 12 additions & 2 deletions src/sensor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -500,8 +500,18 @@ namespace librealsense
std::lock_guard<std::mutex> lock(_power_lock);
if (_user_count.fetch_add(1) == 0)
{
_device->set_power_state(platform::D0);
for (auto&& xu : _xus) _device->init_xu(xu);
try
{
_device->set_power_state( platform::D0 );
for( auto && xu : _xus )
_device->init_xu( xu );
}
catch (...)
{
_user_count.fetch_add( -1 );
LOG_ERROR( "acquire_power failed " );
throw;
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

What about void uvc_sensor::release_power() below - could the fix be applicable there as well?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Its not needed because the fix is for the cases that release_power() didn't call because of exception on acquire_power().

Copy link
Collaborator

Choose a reason for hiding this comment

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

But is it possible that setting D3 would throw?

}
}

Expand Down