summaryrefslogtreecommitdiffstats
path: root/src/server/net.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/server/net.c')
-rw-r--r--src/server/net.c13
1 files changed, 5 insertions, 8 deletions
diff --git a/src/server/net.c b/src/server/net.c
index 12bcdad..00c9a8d 100644
--- a/src/server/net.c
+++ b/src/server/net.c
@@ -270,18 +270,15 @@ void* net_handleNewConnection(void *clientPtr)
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 ( uplink != NULL && ( uplink->cacheFd == -1 || uplink->queueLen > SERVER_UPLINK_QUEUELEN_THRES ) ) {
bOk = ( rand() % 4 ) == 1;
}
- bool penalty = bOk && ( uplink == NULL || uplink->cacheFd == -1 );
- if ( uplink == NULL ) {
- uplink_init( image, -1, NULL, 0 );
- } else {
- ref_put( &uplink->reference );
- }
- if ( penalty ) { // Wait 100ms if local caching is not working so this
+ if ( bOk && uplink != NULL && uplink->cacheFd == -1 ) { // Wait 100ms if local caching is not working so this
usleep( 100000 ); // server gets a penalty and is less likely to be selected
}
+ if ( uplink != NULL ) {
+ ref_put( &uplink->reference );
+ }
}
if ( bOk ) {
mutex_lock( &image->lock );