diff options
author | Simon Rettberg | 2018-07-04 14:39:43 +0200 |
---|---|---|
committer | Simon Rettberg | 2018-07-04 14:39:43 +0200 |
commit | 053ca3b9a9601467d5ce30c56c3cea078c897f57 (patch) | |
tree | 29b60273e13684bb98b1badcd784b6f2b2e4d0f4 /src/server/net.c | |
parent | [SERVER] cmake: Add config option for extra compiler opptions (diff) | |
download | dnbd3-053ca3b9a9601467d5ce30c56c3cea078c897f57.tar.gz dnbd3-053ca3b9a9601467d5ce30c56c3cea078c897f57.tar.xz dnbd3-053ca3b9a9601467d5ce30c56c3cea078c897f57.zip |
[SERVER] Refactor uplink/cache handling, improve crc checking
The cacheFd is now moved to the uplink data structure and will
only be handled by the uplink thread.
The integrity checker now supports checking all blocks of an
image. This will be triggered automatically whenever a check for
a single block failed.
Also, if a crc check on startup fails, the image won't be discarded
anymore, but rather a full check will be initiated.
Furthermore, when calling image_updateCacheMap() on an image that
was previously complete, the cache map will now be re-initialized,
and a new uplink connection created.
Diffstat (limited to 'src/server/net.c')
-rw-r--r-- | src/server/net.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/src/server/net.c b/src/server/net.c index b160778..6fa536f 100644 --- a/src/server/net.c +++ b/src/server/net.c @@ -289,15 +289,17 @@ void* net_handleNewConnection(void *clientPtr) logadd( LOG_DEBUG1, "Client %s requested non-working image '%s' (rid:%d), rejected\n", client->hostName, image_name, (int)rid ); } else { + bool penalty; // Image is fine so far, but occasionally drop a client if the uplink for the image is clogged or unavailable bOk = true; if ( image->cache_map != NULL ) { spin_lock( &image->lock ); - if ( image->uplink == NULL || image->uplink->queueLen > SERVER_UPLINK_QUEUELEN_THRES ) { + if ( image->uplink == NULL || image->uplink->cacheFd == -1 || image->uplink->queueLen > SERVER_UPLINK_QUEUELEN_THRES ) { bOk = ( rand() % 4 ) == 1; } + penalty = bOk && image->uplink != NULL && image->uplink->cacheFd == -1; spin_unlock( &image->lock ); - if ( image->cacheFd == -1 ) { // Wait 100ms if local caching is not working so this + if ( penalty ) { // Wait 100ms if local caching is not working so this usleep( 100000 ); // server gets a penalty and is less likely to be selected } } |