diff options
author | Simon Rettberg | 2020-03-03 14:55:01 +0100 |
---|---|---|
committer | Simon Rettberg | 2020-03-03 14:55:01 +0100 |
commit | 5bc3badd013b88201da64dc970600d19451daaec (patch) | |
tree | d2aec58cfd872302b61c59125daf972e4dc816be /src/server/net.c | |
parent | [SERVER] Remove "working" flag, introduce fine-grained flags (diff) | |
download | dnbd3-5bc3badd013b88201da64dc970600d19451daaec.tar.gz dnbd3-5bc3badd013b88201da64dc970600d19451daaec.tar.xz dnbd3-5bc3badd013b88201da64dc970600d19451daaec.zip |
[SERVER] Also add a flag for uplink queue overload
Diffstat (limited to 'src/server/net.c')
-rw-r--r-- | src/server/net.c | 10 |
1 files changed, 3 insertions, 7 deletions
diff --git a/src/server/net.c b/src/server/net.c index 29147be..a478e0c 100644 --- a/src/server/net.c +++ b/src/server/net.c @@ -269,12 +269,11 @@ void* net_handleNewConnection(void *clientPtr) // Image is fine so far, but occasionally drop a client if the uplink for the image is clogged or unavailable bOk = true; if ( image->ref_cacheMap != NULL ) { - dnbd3_uplink_t *uplink = ref_get_uplink( &image->uplinkref ); - if ( uplink != NULL && ( uplink->cacheFd == -1 || uplink->queueLen > SERVER_UPLINK_QUEUELEN_THRES ) ) { + if ( image->problem.queue || image->problem.write ) { bOk = ( rand() % 4 ) == 1; } - if ( bOk && uplink != NULL ) { - if ( uplink->cacheFd == -1 ) { // Wait 100ms if local caching is not working so this + if ( bOk ) { + if ( image->problem.write ) { // Wait 100ms if local caching is not working so this usleep( 100000 ); // server gets a penalty and is less likely to be selected } if ( image->problem.uplink ) { @@ -282,9 +281,6 @@ void* net_handleNewConnection(void *clientPtr) usleep( ( 100 - image->completenessEstimate ) * 100 ); } } - if ( uplink != NULL ) { - ref_put( &uplink->reference ); - } } if ( bOk ) { mutex_lock( &image->lock ); |