Commit 0b10ccba authored by Eric Cano's avatar Eric Cano
Browse files

Various memory leaks cleanups

Added rados library version validation and cleanup.
Created a new shared library to ensure instantiation of singleton object supporting the former.
Removed several double creations of drive objects in unit tests.
Added cleanup for potentially unused drive objects in unit tests.
parent 106515d4
......@@ -117,7 +117,7 @@ endif (${COMPILE_PACKAGING} STREQUAL "1")
add_custom_target(test tests/unittests
#
#COMMAND valgrind --track-fds=yes --leak-check=full --demangle=no --gen-suppressions=all --show-reachable=yes --error-exitcode=1 test/castorUnitTests
#COMMAND valgrind --track-fds=yes --leak-check=full --demangle=yes --gen-suppressions=all --show-reachable=yes --error-exitcode=1 tests/unittests
#COMMAND test/castorThreadedUnitTests
#COMMAND valgrind --track-fds=yes --leak-check=full --show-reachable=yes --error-exitcode=1 test/castorThreadedUnitTests
#COMMAND valgrind --tool=helgrind -v --demangle=no --conflict-cache-size=30000000 --error-exitcode=1 test/castorThreadedUnitTests
......@@ -125,4 +125,3 @@ add_custom_target(test tests/unittests
#COMMAND valgrind --tool=helgrind --error-exitcode=1 test/castorMultiprocessUnitTests
DEPENDS tests/unittests #test/castorThreadedUnitTests test/castorMultiprocessUnitTests test/castorThreadedUnitTests.supp
COMMENT "Running unit tests" VERBATIM)
......@@ -109,3 +109,4 @@ The shared libraries
%attr(0755,root,root) %{_libdir}/libctanameserver.so
%attr(0755,root,root) %{_libdir}/libctaremotens.so
%attr(0755,root,root) %{_libdir}/libctascheduler.so
%attr(0755,root,root) %{_libdir}/libctaobjectstore.so
\ No newline at end of file
......@@ -30,7 +30,7 @@ SET_SOURCE_FILES_PROPERTIES(${CTAProtoDependants}
PROPERTIES OBJECT_DEPENDS ${CTAProtoHeaders})
add_library (CTAObjectStore
add_library (ctaobjectstore SHARED
${CTAProtoSources}
RootEntry.cpp
Agent.cpp
......@@ -50,8 +50,9 @@ add_library (CTAObjectStore
GenericObject.cpp
GarbageCollector.cpp
SchedulerGlobalLock.cpp)
target_link_libraries(CTAObjectStore Utils rados)
target_link_libraries(ctaobjectstore Utils rados)
set_source_files_properties(BackendRados.cpp PROPERTIES COMPILE_FLAGS -Wno-deprecated-declarations)
install (TARGETS ctaobjectstore DESTINATION usr/${CMAKE_INSTALL_LIBDIR})
set(ObjectStoreUnitTests
BackendTest.cpp
......@@ -63,12 +64,12 @@ set(ObjectStoreUnitTests
add_library(ctaobjectstoreunittests SHARED ${ObjectStoreUnitTests})
target_link_libraries(ctaobjectstoreunittests
protobuf rados ctacommon gtest gmock CTAObjectStore)
protobuf rados ctacommon gtest gmock ctaobjectstore)
add_executable(makeMinimalVFS makeMinimalVFS.cpp)
target_link_libraries(makeMinimalVFS
protobuf CTAObjectStore ctacommon)
protobuf ctaobjectstore ctacommon)
add_executable(listObjectStore listObjectStore.cpp)
target_link_libraries(listObjectStore
protobuf CTAObjectStore ctacommon)
protobuf ctaobjectstore ctacommon)
......@@ -38,7 +38,7 @@ add_library (ctascheduler SHARED
${CTA_SCHEDULER_SRC_FILES})
install (TARGETS ctascheduler DESTINATION usr/${CMAKE_INSTALL_LIBDIR})
target_link_libraries (ctascheduler ${SQLITE3_LIBRARY_RELEASE} ctacommon CTAObjectStore protobuf Utils)
target_link_libraries (ctascheduler ${SQLITE3_LIBRARY_RELEASE} ctacommon ctaobjectstore protobuf Utils)
add_library (ctaschedulerutils SHARED
DummyScheduler.cpp)
......
......@@ -619,10 +619,6 @@ TEST_F(castor_tape_tapeserver_daemon_DataTransferSessionTest, DataTransferSessio
mockSys.delegateToFake();
mockSys.disableGMockCallsCounting();
mockSys.fake.setupForVirtualDriveSLC6();
//delete is unnecessary
//pointer with ownership will be passed to the application,
//which will do the delete
mockSys.fake.m_pathToDrive["/dev/nst0"] = new castor::tape::tapeserver::drive::FakeDrive;
// 4) Create the scheduler
cta::MockNameServer ns;
......@@ -818,10 +814,6 @@ TEST_F(castor_tape_tapeserver_daemon_DataTransferSessionTest, DataTransferSessio
mockSys.delegateToFake();
mockSys.disableGMockCallsCounting();
mockSys.fake.setupForVirtualDriveSLC6();
//delete is unnecessary
//pointer with ownership will be passed to the application,
//which will do the delete
mockSys.fake.m_pathToDrive["/dev/nst0"] = new castor::tape::tapeserver::drive::FakeDrive;
// 4) Create the scheduler
cta::MockNameServer ns;
......@@ -938,10 +930,6 @@ TEST_F(castor_tape_tapeserver_daemon_DataTransferSessionTest, DataTransferSessio
mockSys.delegateToFake();
mockSys.disableGMockCallsCounting();
mockSys.fake.setupForVirtualDriveSLC6();
//delete is unnecessary
//pointer with ownership will be passed to the application,
//which will do the delete
mockSys.fake.m_pathToDrive["/dev/nst0"] = new castor::tape::tapeserver::drive::FakeDrive;
// 4) Create the scheduler
cta::MockNameServer ns;
......@@ -1056,10 +1044,6 @@ TEST_F(castor_tape_tapeserver_daemon_DataTransferSessionTest, DataTransferSessio
mockSys.delegateToFake();
mockSys.disableGMockCallsCounting();
mockSys.fake.setupForVirtualDriveSLC6();
//delete is unnecessary
//pointer with ownership will be passed to the application,
//which will do the delete
mockSys.fake.m_pathToDrive["/dev/nst0"] = new castor::tape::tapeserver::drive::FakeDrive;
// 4) Create the scheduler
cta::MockNameServer ns;
......@@ -1178,10 +1162,6 @@ TEST_F(castor_tape_tapeserver_daemon_DataTransferSessionTest, DataTransferSessio
mockSys.delegateToFake();
mockSys.disableGMockCallsCounting();
mockSys.fake.setupForVirtualDriveSLC6();
//delete is unnecessary
//pointer with ownership will be passed to the application,
//which will do the delete
mockSys.fake.m_pathToDrive["/dev/nst0"] = new castor::tape::tapeserver::drive::FakeDrive;
// 4) Create the scheduler
cta::MockNameServer ns;
......
......@@ -106,7 +106,7 @@ namespace unitTests{
TEST(castor_tape_tapeserver_daemon, DiskReadTaskTest){
char path[]="/tmp/testDRT-XXXXXX";
mkstemp(path);
::close(::mkstemp(path));
std::string url("file://");
url += path;
std::ofstream out(path,std::ios::out | std::ios::binary);
......
......@@ -22,6 +22,7 @@
*****************************************************************************/
#include "castor/tape/tapeserver/drive/FakeDrive.hpp"
#include <iostream>
namespace {
const long unsigned int max_fake_drive_record_length = 1000;
......
......@@ -22,6 +22,7 @@
*****************************************************************************/
#include "Wrapper.hpp"
#include "../drive/DriveInterface.hpp"
#include <errno.h>
#include <limits.h>
#include <stdexcept>
......@@ -216,6 +217,15 @@ void System::fakeWrapper::referenceFiles() {
i != m_stFiles.end(); i++)
m_files[i->first] = &m_stFiles[i->first];
}
/**
* Destructor: delete leftover drive objects
*/
System::fakeWrapper::~fakeWrapper() {
for (auto d=m_pathToDrive.begin(); d!=m_pathToDrive.end(); d++) {
delete d->second;
d->second = NULL;
}
}
System::mockWrapper::mockWrapper() {
m_DIR = reinterpret_cast<DIR*> (& m_DIRfake);
......
......@@ -150,6 +150,8 @@ namespace System {
void setupSLC6();
void setupForVirtualDriveSLC6();
void referenceFiles();
virtual ~fakeWrapper();
private:
struct ourDIR {
......
......@@ -19,7 +19,7 @@ target_link_libraries(unittests
castorutilsunittests
ctacommon
ctacommonunittests
CTAObjectStore
ctaobjectstore
ctaobjectstoreunittests
ctanameserverunittests
ctaremotensunittests
......
......@@ -8,7 +8,7 @@ include_directories(${CMAKE_BINARY_DIR})
include_directories(${CMAKE_SOURCE_DIR}/tapeserver)
add_library (XrdCtaOfs MODULE XrdCtaFilesystem.cpp XrdCtaFile.cpp)
target_link_libraries (XrdCtaOfs ctascheduler ctacommon ctanameserver ctaremotens protobuf CTAObjectStore cryptopp)
target_link_libraries (XrdCtaOfs ctascheduler ctacommon ctanameserver ctaremotens protobuf ctaobjectstore cryptopp)
INSTALL (TARGETS XrdCtaOfs DESTINATION usr/${CMAKE_INSTALL_LIBDIR})
INSTALL (FILES xrd.cf.cta DESTINATION ${CMAKE_INSTALL_SYSCONFDIR})
\ No newline at end of file
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment