From 294b7deaf86dfae9d9d969d39beb417cf3a4ead7 Mon Sep 17 00:00:00 2001 From: James Peach Date: Sat, 3 Jun 2023 12:20:40 +1000 Subject: [PATCH] Break the circular dependency between iocore and tscore. The re-introduction of the MTHashTable class created a dependency from tscore to iocore, since it uses proxy mutexes, which are tightly coupled to the event system. We can break this circular dependency by moving the class into the QUIC library as an implementation detail, since that already depends on the event system This fixes #9768. Signed-off-by: James Peach --- .gitignore | 2 +- .../net/quic/MTHashTable.h | 2 +- iocore/net/quic/Makefile.am | 14 ++++++++++++++ iocore/net/quic/QUICConnectionTable.h | 2 +- .../net/quic/test_MTHashTable.cc | 10 +++++----- src/tscore/CMakeLists.txt | 5 ++--- src/tscore/Makefile.am | 6 ++---- 7 files changed, 26 insertions(+), 15 deletions(-) rename include/tscore/MT_hashtable.h => iocore/net/quic/MTHashTable.h (99%) rename src/tscore/unit_tests/test_MT_hashtable.cc => iocore/net/quic/test_MTHashTable.cc (97%) diff --git a/.gitignore b/.gitignore index 426124c8efb..26c5c1cde91 100644 --- a/.gitignore +++ b/.gitignore @@ -108,7 +108,7 @@ lib/perl/lib/Apache/TS.pm iocore/net/test_certlookup iocore/net/test_UDPNet iocore/net/test_libinknet -iocore/net/quic/test_QUIC* +iocore/net/quic/test_* iocore/aio/test_AIO iocore/eventsystem/test_IOBuffer iocore/eventsystem/test_EventSystem diff --git a/include/tscore/MT_hashtable.h b/iocore/net/quic/MTHashTable.h similarity index 99% rename from include/tscore/MT_hashtable.h rename to iocore/net/quic/MTHashTable.h index 363a856e56f..31d6eaa8592 100644 --- a/include/tscore/MT_hashtable.h +++ b/iocore/net/quic/MTHashTable.h @@ -23,7 +23,7 @@ /**************************************************************************** - MT_hashtable.h + MTHashTable.h Multithread Safe Hash table implementation diff --git a/iocore/net/quic/Makefile.am b/iocore/net/quic/Makefile.am index 42e75986ccd..c4602009dc9 100644 --- a/iocore/net/quic/Makefile.am +++ b/iocore/net/quic/Makefile.am @@ -54,6 +54,20 @@ libquic_a_SOURCES = \ # Check Programs # +check_PROGRAMS := test_MTHashTable + +test_MTHashTable_CPPFLAGS = \ + $(AM_CPPFLAGS) \ + -I$(abs_top_srcdir)/tests/include + +test_MTHashTable_LDADD = \ + $(top_builddir)/iocore/eventsystem/libinkevent.a \ + $(top_builddir)/src/tscore/libtscore.la \ + $(top_builddir)/src/tscpp/util/libtscpputil.la \ + @SWOC_LIBS@ @OPENSSL_LIBS@ + +test_MTHashTable_SOURCES = test_MTHashTable.cc + TESTS = $(check_PROGRAMS) # diff --git a/iocore/net/quic/QUICConnectionTable.h b/iocore/net/quic/QUICConnectionTable.h index 4be207a492e..edd0bd53f00 100644 --- a/iocore/net/quic/QUICConnectionTable.h +++ b/iocore/net/quic/QUICConnectionTable.h @@ -25,7 +25,7 @@ #include "QUICTypes.h" #include "QUICConnection.h" -#include "tscore/MT_hashtable.h" +#include "MTHashTable.h" class QUICConnectionTable { diff --git a/src/tscore/unit_tests/test_MT_hashtable.cc b/iocore/net/quic/test_MTHashTable.cc similarity index 97% rename from src/tscore/unit_tests/test_MT_hashtable.cc rename to iocore/net/quic/test_MTHashTable.cc index deb153309da..38531ee5c14 100644 --- a/src/tscore/unit_tests/test_MT_hashtable.cc +++ b/iocore/net/quic/test_MTHashTable.cc @@ -20,13 +20,13 @@ See the License for the specific language governing permissions and limitations under the License. */ -#include -#include "tscore/ink_platform.h" -#include "P_EventSystem.h" -#include "tscore/MT_hashtable.h" -#include "I_Lock.h" + +#define CATCH_CONFIG_MAIN #include +#include "P_EventSystem.h" +#include "MTHashTable.h" + // ------------- // --- TESTS --- // ------------- diff --git a/src/tscore/CMakeLists.txt b/src/tscore/CMakeLists.txt index ab5e5b66e6c..79a3a39b6b9 100644 --- a/src/tscore/CMakeLists.txt +++ b/src/tscore/CMakeLists.txt @@ -123,7 +123,6 @@ add_executable(test_tscore unit_tests/test_IntrusivePtr.cc unit_tests/test_List.cc unit_tests/test_MMH.cc - unit_tests/test_MT_hashtable.cc unit_tests/test_ParseRules.cc unit_tests/test_PluginUserArgs.cc unit_tests/test_PriorityQueue.cc @@ -140,7 +139,7 @@ add_executable(test_tscore unit_tests/test_scoped_resource.cc unit_tests/unit_test_main.cc ) -target_link_libraries(test_tscore PRIVATE tscore inkevent records_p libswoc) -target_include_directories(test_tscore PRIVATE ${CMAKE_SOURCE_DIR}/include ${CMAKE_SOURCE_DIR}/iocore/eventsystem ${CATCH_INCLUDE_DIR}) +target_link_libraries(test_tscore PRIVATE tscore libswoc) +target_include_directories(test_tscore PRIVATE ${CMAKE_SOURCE_DIR}/include ${CATCH_INCLUDE_DIR}) install(TARGETS tscore) diff --git a/src/tscore/Makefile.am b/src/tscore/Makefile.am index 5a5f0ef1aee..2bf5a911a3c 100644 --- a/src/tscore/Makefile.am +++ b/src/tscore/Makefile.am @@ -34,8 +34,7 @@ TESTS = $(check_PROGRAMS) lib_LTLIBRARIES = libtscore.la AM_CPPFLAGS += \ - $(iocore_include_dirs) \ - @SWOC_INCLUDES@ \ + @SWOC_INCLUDES@ \ -I$(abs_top_srcdir)/include \ -I$(abs_top_srcdir)/lib \ $(TS_INCLUDES) \ @@ -164,7 +163,7 @@ test_tscore_CPPFLAGS = $(AM_CPPFLAGS)\ -I$(abs_top_srcdir)/tests/include test_tscore_CXXFLAGS = -Wno-array-bounds $(AM_CXXFLAGS) -test_tscore_LDADD = libtscore.la $(top_builddir)/src/tscpp/util/libtscpputil.la $(top_builddir)/iocore/eventsystem/libinkevent.a @SWOC_LIBS@ @OPENSSL_LIBS@ +test_tscore_LDADD = libtscore.la $(top_builddir)/src/tscpp/util/libtscpputil.la @SWOC_LIBS@ @OPENSSL_LIBS@ test_tscore_SOURCES = \ unit_tests/unit_test_main.cc \ unit_tests/test_AcidPtr.cc \ @@ -183,7 +182,6 @@ test_tscore_SOURCES = \ unit_tests/test_IntrusivePtr.cc \ unit_tests/test_layout.cc \ unit_tests/test_List.cc \ - unit_tests/test_MT_hashtable.cc \ unit_tests/test_ParseRules.cc \ unit_tests/test_PluginUserArgs.cc \ unit_tests/test_PriorityQueue.cc \