From a7d4e73493047f077a1b90f83816f2b2b60a85fd Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Mon, 19 Mar 2018 16:48:53 +0100 Subject: [SERVER] image_getCompletenessEstimate: Fix reversed logic in timeout check --- src/server/image.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src/server') diff --git a/src/server/image.c b/src/server/image.c index 3823a36..2b7c63b 100644 --- a/src/server/image.c +++ b/src/server/image.c @@ -927,6 +927,8 @@ static bool image_load(char *base, char *path, int withUplink) image->readFd = -1; image->cacheFd = -1; image->working = (image->cache_map == NULL ); + timing_get( &image->nextCompletenessEstimate ); + image->completenessEstimate = -1; spin_init( &image->lock, PTHREAD_PROCESS_PRIVATE ); int32_t offset; if ( stat( path, &st ) == 0 ) { @@ -1605,7 +1607,7 @@ int image_getCompletenessEstimate(dnbd3_image_t * const image) assert( image != NULL ); if ( image->cache_map == NULL ) return image->working ? 100 : 0; declare_now; - if ( timing_reached( &image->nextCompletenessEstimate, &now ) ) { + if ( !timing_reached( &image->nextCompletenessEstimate, &now ) ) { // Since this operation is relatively expensive, we cache the result for a while return image->completenessEstimate; } -- cgit v1.2.3-55-g7522