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

Backport to 9: fixes for gzserver shutdown and ogre log test #2968

Merged
merged 3 commits into from
Apr 21, 2021
Merged
Show file tree
Hide file tree
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
7 changes: 3 additions & 4 deletions gazebo/transport/ConnectionManager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,9 @@ void ConnectionManager::Fini()
return;

this->Stop();
if (this->initialized)
while (this->stopped == false)
common::Time::MSleep(100);

if (this->masterConn)
{
Expand Down Expand Up @@ -244,10 +247,6 @@ void ConnectionManager::Fini()
void ConnectionManager::Stop()
{
this->stop = true;
this->updateCondition.notify_all();
if (this->initialized)
while (this->stopped == false)
common::Time::MSleep(100);
}

//////////////////////////////////////////////////
Expand Down
19 changes: 10 additions & 9 deletions plugins/DepthCameraPlugin.cc
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,20 @@
*/

#include <functional>
#include <mutex>
#include <unordered_map>

#include "plugins/DepthCameraPlugin.hh"

using namespace gazebo;
GZ_REGISTER_SENSOR_PLUGIN(DepthCameraPlugin)

std::mutex global_maps_mutex;

// Added this map to avoid breaking the ABI
static std::map<DepthCameraPlugin*, event::ConnectionPtr>
static std::unordered_map<DepthCameraPlugin*, event::ConnectionPtr>
connection_reflectance_map;
static std::map<DepthCameraPlugin*, event::ConnectionPtr>
static std::unordered_map<DepthCameraPlugin*, event::ConnectionPtr>
connection_normals_map;
/////////////////////////////////////////////////
DepthCameraPlugin::DepthCameraPlugin()
Expand All @@ -40,13 +44,9 @@ DepthCameraPlugin::~DepthCameraPlugin()
this->newRGBPointCloudConnection.reset();
this->newImageFrameConnection.reset();

std::map<DepthCameraPlugin*, event::ConnectionPtr>::iterator it;
it = connection_reflectance_map.find(this);
it->second.reset();
connection_reflectance_map.erase(it);
it = connection_normals_map.find(this);
it->second.reset();
connection_normals_map.erase(it);
std::lock_guard<std::mutex> guard{global_maps_mutex};
connection_reflectance_map.erase(this);
connection_normals_map.erase(this);

this->parentSensor.reset();
this->depthCamera.reset();
Expand Down Expand Up @@ -93,6 +93,7 @@ void DepthCameraPlugin::Load(sensors::SensorPtr _sensor,
std::placeholders::_3, std::placeholders::_4,
std::placeholders::_5));

std::lock_guard<std::mutex> guard{global_maps_mutex};
connection_reflectance_map.
insert(std::pair<DepthCameraPlugin*, event::ConnectionPtr>
(this, newReflectanceFrameConnection));
Expand Down
17 changes: 14 additions & 3 deletions test/integration/ogre_log.cc
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,20 @@ TEST_F(OgreLog, LogError)
if (line.find(" GL_EXTENSIONS =") < 12)
continue;

EXPECT_EQ(line.find("Error"), std::string::npos);
EXPECT_EQ(line.find("error"), std::string::npos);
EXPECT_EQ(line.find("ERROR"), std::string::npos);
// A GLX extension may have the word "error" in its name. For example:
// GLX_ARB_create_context_no_error.
// We will skip the line that lists all the extensions. This line starts
// with a date, so we just check that "Supported GLX extensions:" is
// toward the beginning.
// False positive cppcheck
// https://sourceforge.net/p/cppcheck/discussion/general/thread/0c113d65/
// cppcheck-suppress stlIfStrFind
if (line.find(" Supported GLX extensions: ") < 12)
continue;

EXPECT_EQ(line.find("Error"), std::string::npos) << line;
EXPECT_EQ(line.find("error"), std::string::npos) << line;
EXPECT_EQ(line.find("ERROR"), std::string::npos) << line;
}
}

Expand Down