diff options
author | Simon Rettberg | 2018-04-12 23:29:28 +0200 |
---|---|---|
committer | Simon Rettberg | 2018-04-12 23:29:28 +0200 |
commit | 26d356fa2c253affac69543298accca6406045ca (patch) | |
tree | 306594db4d3f65b101f469ca9ad4b0d8a1210d42 /src/server/uplink.c | |
parent | [SERVER] Mark spammy replication messages as DEBUG2 instead of 1 (diff) | |
download | dnbd3-26d356fa2c253affac69543298accca6406045ca.tar.gz dnbd3-26d356fa2c253affac69543298accca6406045ca.tar.xz dnbd3-26d356fa2c253affac69543298accca6406045ca.zip |
[SERVER] Add bgrMinClients: Thresold to control when BGR starts
Background replication will not kick in if there aren't at least
that many clients connected.
Diffstat (limited to 'src/server/uplink.c')
-rw-r--r-- | src/server/uplink.c | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/src/server/uplink.c b/src/server/uplink.c index 2cf8b7d..debd091 100644 --- a/src/server/uplink.c +++ b/src/server/uplink.c @@ -375,7 +375,10 @@ static void* uplink_mainloop(void *data) declare_now; if ( link->fd != -1 && link->replicationHandle == 0 && timing_reached( &nextKeepalive, &now ) ) { timing_set( &nextKeepalive, &now, 20 ); - if ( !uplink_sendKeepalive( link->fd ) ) { + if ( uplink_sendKeepalive( link->fd ) ) { + // Re-trigger periodically, in case it requires a minimum user count + uplink_sendReplicationRequest( link ); + } else { const int fd = link->fd; link->fd = -1; close( fd ); @@ -514,8 +517,8 @@ static void uplink_sendReplicationRequest(dnbd3_connection_t *link) dnbd3_image_t * const image = link->image; if ( image->realFilesize < DNBD3_BLOCK_SIZE ) return; spin_lock( &image->lock ); - if ( image == NULL || image->cache_map == NULL || link->replicationHandle != 0 ) { - // No cache map (=image complete), or replication pending, do nothing + if ( image == NULL || image->cache_map == NULL || link->replicationHandle != 0 || image->users < _bgrMinClients ) { + // No cache map (=image complete), or replication pending, or not enough users, do nothing spin_unlock( &image->lock ); return; } |