diff --git a/configs/export-lib-symbols b/configs/export-lib-symbols index 0ec4802..62fadb9 100644 --- a/configs/export-lib-symbols +++ b/configs/export-lib-symbols @@ -1,6 +1,7 @@ { global: - TcpMonPin; + *TcpMonPin*; + *TCPStats*; local: *; diff --git a/src/tcpstats.cpp b/src/tcpstats.cpp index 06bce78..4cbecb0 100644 --- a/src/tcpstats.cpp +++ b/src/tcpstats.cpp @@ -33,25 +33,13 @@ void TCPStats::Monitor(int fd, XrdNetAddrInfo &netInfo, const char *tident) socklen_t tcp_info_length = sizeof(tcp_info); int sockopt_rc = getsockopt( fd, SOL_TCP, TCP_INFO, (void *)&tcp_info, &tcp_info_length ); if ( sockopt_rc == 0 ) { - auto returnedJSON = TCPStats::GenerateJSON(tcp_info, netInfo); + std::string returnedJSON = TCPStats::GenerateJSON(tcp_info, netInfo); + + // Insert the JSON into the gstream + // Include the null terminated character in the count + this->stream->Insert(returnedJSON.c_str(), returnedJSON.length()+1); + } - // Create the json object - /* - int sprintf_rc = sprintf(statistics, - "connect=%s bytes_in=%llu bytes_out=%llu rtt=%u rttvar=%u unacked=%u sacked=%u " - "lost=%u retrans=%u reordering=%u", - addr_str, - LinkBytesIn, - LinkBytesOut, - tcp_info.tcpi_rtt, - tcp_info.tcpi_rttvar, - tcp_info.tcpi_unacked, - tcp_info.tcpi_sacked, - tcp_info.tcpi_lost, - tcp_info.tcpi_retrans, - tcp_info.tcpi_reordering - ); - */ } diff --git a/src/tcpstats.h b/src/tcpstats.h index 78971b3..0e302d0 100644 --- a/src/tcpstats.h +++ b/src/tcpstats.h @@ -27,6 +27,8 @@ class TCPStats: public XrdTcpMonPin { class TcpMonPin : public XrdOucPinObject { public: + TcpMonPin() {}; + virtual ~TcpMonPin() {}; XrdTcpMonPin *getInstance(const char *parms, XrdOucEnv &envR, XrdSysLogger &logR, diff --git a/test/main.cpp b/test/main.cpp index f268a22..2eabd0c 100644 --- a/test/main.cpp +++ b/test/main.cpp @@ -8,11 +8,28 @@ #include #include #include +#include namespace { + +TEST(TestLoad, DynTestLoad) { + + void* handle = dlopen("libXrdTCPStats-5.so", RTLD_LAZY); + ASSERT_NE(handle, nullptr); + + void* tcp_mon = dlsym(handle, "TcpMonPin"); + + char* error = dlerror(); + if (error) + std::cout << error << std::endl; + + ASSERT_NE(tcp_mon, nullptr); + +} + class TCPTest : public ::testing::Test { protected: void SetUp() override { @@ -82,6 +99,8 @@ TEST_F(TCPTest, GenerateJSON) { } + + } int main(int argc, char **argv) {