summaryrefslogtreecommitdiffstats
path: root/src/server/globals.h
diff options
context:
space:
mode:
authorSimon Rettberg2018-08-08 12:09:14 +0200
committerSimon Rettberg2018-08-08 12:09:14 +0200
commit2860f3393025e114f11feb1b576d2ac6353fbd23 (patch)
tree51a66fbf9dccff3ee0d7cc905cab7c7ab40911b5 /src/server/globals.h
parent[SHARED] Use atomic for logger mask (diff)
downloaddnbd3-2860f3393025e114f11feb1b576d2ac6353fbd23.tar.gz
dnbd3-2860f3393025e114f11feb1b576d2ac6353fbd23.tar.xz
dnbd3-2860f3393025e114f11feb1b576d2ac6353fbd23.zip
[SERVER] Use atomic var for (total)bytesSent counters
Gets rid of the lastBytesSent field as well as the stats lock per client. Cleaned and split up the messy net_clientsToJson function while at it.
Diffstat (limited to 'src/server/globals.h')
-rw-r--r--src/server/globals.h12
1 files changed, 5 insertions, 7 deletions
diff --git a/src/server/globals.h b/src/server/globals.h
index c384ac6..84588c3 100644
--- a/src/server/globals.h
+++ b/src/server/globals.h
@@ -127,16 +127,14 @@ struct _dnbd3_image
struct _dnbd3_client
{
#define HOSTNAMELEN (48)
- uint64_t bytesSent; // Byte counter for this client. Use statsLock when accessing.
- uint64_t lastBytesSent; // Byte counter from when we last added to global counter. Use statsLock when accessing.
- dnbd3_image_t *image;
+ atomic_uint_fast64_t bytesSent; // Byte counter for this client.
+ dnbd3_image_t *image; // Image in use by this client, or NULL during handshake
int sock;
- bool isServer; // true if a server in proxy mode, false if real client
+ bool isServer; // true if a server in proxy mode, false if real client
dnbd3_host_t host;
- char hostName[HOSTNAMELEN];
- pthread_mutex_t sendMutex;
+ char hostName[HOSTNAMELEN]; // inet_ntop version of host
+ pthread_mutex_t sendMutex; // Held while writing to sock if image is incomplete (since uplink uses socket too)
pthread_spinlock_t lock;
- pthread_spinlock_t statsLock;
};
// #######################################################