summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorSimon Rettberg2019-08-18 18:18:16 +0200
committerSimon Rettberg2019-08-18 18:18:16 +0200
commit573e620bb1811fe81c64b86aeb5728e0437eea9f (patch)
tree11e4e3ab89c3116265b6fa6d7aa6a879a87012c5 /src
parent[SERVER] Lock free thread pool (diff)
downloaddnbd3-573e620bb1811fe81c64b86aeb5728e0437eea9f.tar.gz
dnbd3-573e620bb1811fe81c64b86aeb5728e0437eea9f.tar.xz
dnbd3-573e620bb1811fe81c64b86aeb5728e0437eea9f.zip
[SERVER] net.c: Minor reordering
Diffstat (limited to 'src')
-rw-r--r--src/server/net.c17
1 files changed, 9 insertions, 8 deletions
diff --git a/src/server/net.c b/src/server/net.c
index 8f97a12..5de9f14 100644
--- a/src/server/net.c
+++ b/src/server/net.c
@@ -532,16 +532,15 @@ exit_client_cleanup: ;
removeFromList( client );
totalBytesSent += client->bytesSent;
// Access time, but only if client didn't just probe
- if ( image != NULL ) {
+ if ( image != NULL && client->bytesSent > DNBD3_BLOCK_SIZE * 10 ) {
mutex_lock( &image->lock );
- if ( client->bytesSent > DNBD3_BLOCK_SIZE * 10 ) {
- timing_get( &image->atime );
- }
+ timing_get( &image->atime );
mutex_unlock( &image->lock );
}
freeClientStruct( client ); // This will also call image_release on client->image
return NULL ;
fail_preadd: ;
+ // This is before we even initialized any mutex
close( client->sock );
free( client );
return NULL;
@@ -688,15 +687,17 @@ static void removeFromList(dnbd3_client_t *client)
static dnbd3_client_t* freeClientStruct(dnbd3_client_t *client)
{
mutex_lock( &client->lock );
- mutex_lock( &client->sendMutex );
- if ( client->sock != -1 ) close( client->sock );
- client->sock = -1;
- mutex_unlock( &client->sendMutex );
if ( client->image != NULL ) {
mutex_lock( &client->image->lock );
if ( client->image->uplink != NULL ) uplink_removeClient( client->image->uplink, client );
mutex_unlock( &client->image->lock );
}
+ mutex_lock( &client->sendMutex );
+ if ( client->sock != -1 ) {
+ close( client->sock );
+ }
+ client->sock = -1;
+ mutex_unlock( &client->sendMutex );
mutex_unlock( &client->lock );
client->image = image_release( client->image );
mutex_destroy( &client->lock );