Skip to content

Commit

Permalink
Update from testing
Browse files Browse the repository at this point in the history
  • Loading branch information
djw8605 committed May 28, 2020
1 parent 0bd1c93 commit 69b277b
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 19 deletions.
3 changes: 2 additions & 1 deletion configs/export-lib-symbols
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
global:
TcpMonPin;
*TcpMonPin*;
*TCPStats*;

local:
*;
Expand Down
24 changes: 6 additions & 18 deletions src/tcpstats.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
);
*/

}

Expand Down
2 changes: 2 additions & 0 deletions src/tcpstats.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ class TCPStats: public XrdTcpMonPin {
class TcpMonPin : public XrdOucPinObject<XrdTcpMonPin>
{
public:
TcpMonPin() {};
virtual ~TcpMonPin() {};
XrdTcpMonPin *getInstance(const char *parms,
XrdOucEnv &envR,
XrdSysLogger &logR,
Expand Down
19 changes: 19 additions & 0 deletions test/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,28 @@
#include <netdb.h>
#include <string>
#include <picojson.h>
#include <dlfcn.h>


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 {
Expand Down Expand Up @@ -82,6 +99,8 @@ TEST_F(TCPTest, GenerateJSON) {

}



}

int main(int argc, char **argv) {
Expand Down

0 comments on commit 69b277b

Please sign in to comment.