summaryrefslogtreecommitdiffstats
path: root/src/server/uplink.c
diff options
context:
space:
mode:
authorStephan Schwaer2015-05-04 17:23:42 +0200
committerStephan Schwaer2015-05-04 17:23:42 +0200
commitfa900b4658b21294682760bdf84071cbb2b79aa4 (patch)
treea5ed190f304b88638c7440eadb44cf40fb16b2f2 /src/server/uplink.c
parent[SERVER] PoC RPC interface (diff)
downloaddnbd3-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/uplink.c')
-rw-r--r--src/server/uplink.c20
1 files changed, 17 insertions, 3 deletions
diff --git a/src/server/uplink.c b/src/server/uplink.c
index b5bd981..d76f030 100644
--- a/src/server/uplink.c
+++ b/src/server/uplink.c
@@ -40,6 +40,22 @@ void uplink_globalsInit()
spin_init( &statisticsReceivedLock, PTHREAD_PROCESS_PRIVATE );
}
+uint64_t uplink_getTotalBytesReceived()
+{
+ spin_lock( &statisticsReceivedLock );
+ int tmp = totalBytesReceived;
+ spin_unlock( &statisticsReceivedLock );
+ return tmp;
+}
+
+void uplink_addTotalBytesReceived(int receivedBytes)
+{
+ spin_lock( &statisticsReceivedLock );
+ totalBytesReceived += receivedBytes;
+ spin_unlock( &statisticsReceivedLock );
+ return;
+}
+
/**
* Create and initialize an uplink instance for the given
* image. Uplinks run in their own thread.
@@ -436,9 +452,7 @@ static void* uplink_mainloop(void *data)
spin_destroy( &link->queueLock );
free( link->recvBuffer );
link->recvBuffer = NULL;
- spin_lock( &statisticsReceivedLock );
- totalBytesReceived += link->bytesReceived;
- spin_unlock( &statisticsReceivedLock );
+ uplink_addTotalBytesReceived( link->bytesReceived );
free( link );
return NULL ;
}