Skip to content

Commit

Permalink
cf-serverd now stats file every read on network transmission
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
larsewi committed Oct 21, 2024
1 parent 5272708 commit b66d61d
Showing 1 changed file with 4 additions and 14 deletions.
18 changes: 4 additions & 14 deletions cf-serverd/server_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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)
Expand Down

0 comments on commit b66d61d

Please sign in to comment.