diff options
author | Stephan Schwaer | 2015-05-04 17:23:42 +0200 |
---|---|---|
committer | Stephan Schwaer | 2015-05-04 17:23:42 +0200 |
commit | fa900b4658b21294682760bdf84071cbb2b79aa4 (patch) | |
tree | a5ed190f304b88638c7440eadb44cf40fb16b2f2 /src/server/net.c | |
parent | [SERVER] PoC RPC interface (diff) | |
download | dnbd3-fa900b4658b21294682760bdf84071cbb2b79aa4.tar.gz dnbd3-fa900b4658b21294682760bdf84071cbb2b79aa4.tar.xz dnbd3-fa900b4658b21294682760bdf84071cbb2b79aa4.zip |
Removed dnbd3_printClients, added clients to statistics json in rpc.
Diffstat (limited to 'src/server/net.c')
-rw-r--r-- | src/server/net.c | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/src/server/net.c b/src/server/net.c index 2edb398..dc53701 100644 --- a/src/server/net.c +++ b/src/server/net.c @@ -116,6 +116,22 @@ static inline bool send_reply(int sock, dnbd3_reply_t *reply, void *payload) return true; } +uint64_t net_getTotalBytesSent() +{ + spin_lock( &statisticsSentLock ); + uint64_t tmp = totalBytesSent; + spin_unlock( &statisticsSentLock ); + return tmp; +} + +void net_addTotalBytesSent(uint64_t sentBytes) +{ + spin_lock( &statisticsSentLock ); + totalBytesSent += sentBytes; + spin_unlock( &statisticsSentLock ); + return; +} + void net_init() { spin_init( &statisticsSentLock, PTHREAD_PROCESS_PRIVATE ); @@ -372,9 +388,7 @@ set_name: ; } exit_client_cleanup: ; dnbd3_removeClient( client ); - spin_lock( &statisticsSentLock ); - totalBytesSent += client->bytesSent; // Add the amount of bytes send to statistics of the server. - spin_unlock( &statisticsSentLock ); + net_addTotalBytesSent( client->bytesSent ); // Add the amount of bytes sent by the client to the statistics of the server. client = dnbd3_freeClient( client ); return NULL ; } |