Skip to content

Commit

Permalink
Fix PluginManager teardown.
Browse files Browse the repository at this point in the history
  • Loading branch information
abellgithub committed Jan 6, 2016
1 parent cf3fb8d commit a4c5b2c
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 3 deletions.
9 changes: 8 additions & 1 deletion src/DynamicLibrary.cpp
Expand Up @@ -43,7 +43,7 @@
#include <dlfcn.h>
#endif

#include "DynamicLibrary.h"
#include "DynamicLibrary.hpp"
#include <sstream>
#include <iostream>

Expand All @@ -62,6 +62,13 @@ DynamicLibrary::~DynamicLibrary()
}
}


void DynamicLibrary::clear()
{
m_handle = NULL;
}


DynamicLibrary *DynamicLibrary::load(const std::string &name,
std::string &errorString)
{
Expand Down
1 change: 1 addition & 0 deletions src/DynamicLibrary.h → src/DynamicLibrary.hpp
Expand Up @@ -52,6 +52,7 @@ class DynamicLibrary

~DynamicLibrary();
void *getSymbol(const std::string& name);
void clear();

private:
DynamicLibrary(void *handle) : m_handle(handle)
Expand Down
13 changes: 12 additions & 1 deletion src/PluginManager.cpp
Expand Up @@ -47,7 +47,7 @@
#include <pdal/util/Utils.hpp>
#include <pdal/Log.hpp>

#include "DynamicLibrary.h"
#include "DynamicLibrary.hpp"

#include <memory>
#include <sstream>
Expand Down Expand Up @@ -253,6 +253,17 @@ bool PluginManager::shutdown()
}
}

// This clears the handles on the dynamic libraries so that they won't
// be closed with dlclose(). Depending on the order of dll unloading,
// it's possible for a plugin library to be unloaded before this function
// (which is usually in a dll) is called, which can raise an error on
// some systems when dlclose() is called on a library for which the
// reference count is already 0. Since we're exiting anyway and all the
// dlls will be closed, there is no need to call dlclose() on them
// explicitly.
for (auto l : m_dynamicLibraryMap)
l.second->clear();

m_dynamicLibraryMap.clear();
m_plugins.clear();
m_exitFuncVec.clear();
Expand Down
2 changes: 1 addition & 1 deletion test/unit/CMakeLists.txt
Expand Up @@ -67,7 +67,7 @@ PDAL_ADD_TEST(pdal_pipeline_manager_test FILES PipelineManagerTest.cpp)
PDAL_ADD_TEST(pdal_point_view_test FILES PointViewTest.cpp)
PDAL_ADD_TEST(pdal_point_table_test FILES PointTableTest.cpp)
PDAL_ADD_TEST(pdal_spatial_reference_test FILES SpatialReferenceTest.cpp)
#PDAL_ADD_TEST(pdal_stage_factory_test FILES StageFactoryTest.cpp)
PDAL_ADD_TEST(pdal_stage_factory_test FILES StageFactoryTest.cpp)
PDAL_ADD_TEST(pdal_streaming_test FILES StreamingTest.cpp)
PDAL_ADD_TEST(pdal_support_test FILES SupportTest.cpp)
PDAL_ADD_TEST(pdal_user_callback_test FILES UserCallbackTest.cpp)
Expand Down

0 comments on commit a4c5b2c

Please sign in to comment.