summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 0944585)
raw | patch | inline | side by side (parent: 0944585)
author | Manuel Luis SanmartĂn Rozada <manuel.luis@gmail.com> | |
Wed, 20 May 2015 15:10:41 +0000 (17:10 +0200) | ||
committer | Florian Forster <octo@collectd.org> | |
Tue, 16 Jun 2015 19:50:31 +0000 (21:50 +0200) |
to prevent the creation of the same file at the same time multiple times
and obtain a corrupt rrd file.
and obtain a corrupt rrd file.
src/utils_rrdcreate.c | patch | blob | history |
diff --git a/src/utils_rrdcreate.c b/src/utils_rrdcreate.c
index 5368059e57e06daac597d47cd4dc4a13a3a3d233..da4a944afc60f3c0870aa04b0b1e11bc01df2a02 100644 (file)
--- a/src/utils_rrdcreate.c
+++ b/src/utils_rrdcreate.c
}
else /* synchronous */
{
- status = srrd_create (filename, stepsize, last_up,
- argc, (const char **) argv);
-
+ status = lock_file (filename);
if (status != 0)
{
- WARNING ("cu_rrd_create_file: srrd_create (%s) returned status %i.",
- filename, status);
+ if (status == EEXIST)
+ NOTICE ("cu_rrd_create_file: File \"%s\" is already being created.",
+ filename);
+ else
+ ERROR ("cu_rrd_create_file: Unable to lock file \"%s\".",
+ filename);
}
else
{
- DEBUG ("cu_rrd_create_file: Successfully created RRD file \"%s\".",
- filename);
+ status = srrd_create (filename, stepsize, last_up,
+ argc, (const char **) argv);
+
+ if (status != 0)
+ {
+ WARNING ("cu_rrd_create_file: srrd_create (%s) returned status %i.",
+ filename, status);
+ }
+ else
+ {
+ DEBUG ("cu_rrd_create_file: Successfully created RRD file \"%s\".",
+ filename);
+ }
+ unlock_file (filename);
}
}