aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/el-file.c10
-rw-r--r--tst/test-el-file.c24
2 files changed, 34 insertions, 0 deletions
diff --git a/src/el-file.c b/src/el-file.c
index dd98392..34d2cbc 100644
--- a/src/el-file.c
+++ b/src/el-file.c
@@ -554,6 +554,16 @@ int el_file_flush
VALID(EBADF, el->fcurrent_log);
VALID(EBADF, el->fcurrent_log[0] != '\0');
+ if (el->fwritten_after_sync == 0)
+ {
+ /* if now writes have been performed between consecutive
+ * flush, then don't flush - since there is nothing to
+ * flush anyway
+ */
+
+ return 0;
+ }
+
/* first flush data from stdio library buffers into kernel
*/
diff --git a/tst/test-el-file.c b/tst/test-el-file.c
index cfd524f..ad98061 100644
--- a/tst/test-el-file.c
+++ b/tst/test-el-file.c
@@ -1552,6 +1552,29 @@ static void file_sync_via_flush_function(void)
========================================================================== */
+static void file_consecutive_sync_with_flush_function(void)
+{
+ el_option(EL_FSYNC_EVERY, 16);
+ mt_fok(el_puts(s8));
+ mt_fail(file_synced == 0);
+ mt_fok(el_flush());
+ mt_fail(file_synced == 1);
+ file_synced = 0;
+ mt_fok(el_flush());
+ mt_fail(file_synced == 0);
+ mt_fok(el_flush());
+ mt_fail(file_synced == 0);
+ mt_fok(el_puts(s8));
+ mt_fail(file_synced == 0);
+ mt_fok(el_flush());
+ mt_fail(file_synced == 1);
+}
+
+
+/* ==========================================================================
+ ========================================================================== */
+
+
static void file_sync_periodic(void)
{
el_option(EL_FSYNC_EVERY, 8);
@@ -1889,6 +1912,7 @@ void el_file_test_group(void)
mt_run(file_sync_periodic);
mt_run(file_sync_level);
mt_run(file_sync_via_flush_function);
+ mt_run(file_consecutive_sync_with_flush_function);
rmdir(WORKDIR);
#endif