From 2ef2f8b39fe34cc84e0b2d9bcb59abebba2c8592 Mon Sep 17 00:00:00 2001 From: Lars Erik Wik Date: Mon, 21 Oct 2024 16:31:02 +0200 Subject: [PATCH] cf-serverd now stats file every read on network transmission Previously the file was stat'ed every N read to detect if file changes during transmission. The reason for limiting the calls to stat is probably to make the code more efficient. However, there are reasons to believe that the bug experienced in ENT-12033 is attributed to filechanges during transmission. Hence, I'm changing the code to do this for every read, as it better to be safe than fast. Ticket: None Changelog: None Signed-off-by: Lars Erik Wik --- cf-serverd/server_common.c | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) diff --git a/cf-serverd/server_common.c b/cf-serverd/server_common.c index 6322a1a9d2..f77a33f81e 100644 --- a/cf-serverd/server_common.c +++ b/cf-serverd/server_common.c @@ -459,13 +459,6 @@ void CfGetFile(ServerFileGetState *args) } else { - int div = 3; - - if (sb.st_size > 10485760L) /* File larger than 10 MB, checks every 64kB */ - { - div = 32; - } - while (true) { memset(sendbuffer, 0, CF_BUFSIZE); @@ -488,14 +481,11 @@ void CfGetFile(ServerFileGetState *args) /* check the file is not changing at source */ - if (count++ % div == 0) /* Don't do this too often */ + if (stat(filename, &sb)) { - if (stat(filename, &sb)) - { - Log(LOG_LEVEL_ERR, "Cannot stat file '%s'. (stat: %s)", - filename, GetErrorStr()); - break; - } + Log(LOG_LEVEL_ERR, "Cannot stat file '%s'. (stat: %s)", + filename, GetErrorStr()); + break; } if (sb.st_size != savedlen)