commit da90140e8d47b04aa9aeed9595dac86e97f918ef
parent f9db651188ac908fdac98d955ee733ef42d333e7
Author: Vincent Forest <vincent.forest@meso-star.com>
Date: Thu, 6 Mar 2025 16:59:18 +0100
Update the filename of the dumped state cache
Add its size. By comparing it with its actual size, this identifies that
the file has not been fully written due to an external event.
Diffstat:
1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/src/ssp_rng_proxy.c b/src/ssp_rng_proxy.c
@@ -248,20 +248,20 @@ rng_state_cache_dump(struct rng_state_cache* cache)
} \
} (void)0
+ /* Requests the offset at the end of the file,
+ * i.e. the size of the cache stream */
+ TRY(fseek(cache->stream, 0, SEEK_END) == 0, errno);
+ TRY((offset = ftell(cache->stream)) >= 0, errno);
+
/* Define the state cache filename */
- n = snprintf(name, sizeof(name), "rng_cache_r%lu_w%lu_%d",
- cache->read, cache->write, process);
+ n = snprintf(name, sizeof(name), "rng_cache_r%lu_w%lu_s%ld_%d",
+ cache->read, cache->write, offset, process);
TRY(n >= 0, errno);
TRY((unsigned long)n < sizeof(name), ENOMEM);
/* Create the output file */
TRY((fp = fopen(name, "w")) != NULL, errno);
- /* Requests the offset at the end of the file,
- * i.e. the size of the cache stream */
- TRY(fseek(cache->stream, 0, SEEK_END) == 0, errno);
- TRY((offset = ftell(cache->stream)) >= 0, errno);
-
rewind(cache->stream);
/* Load cache stream in mem, and then dump it to the state cache */