This is an automated email from the git hooks/post-receive script.

git pushed a commit to branch master
in repository efl.

View the commit online.

commit e9e40eb6107315ac8df4004f72d46d8f9d554aea
Author: Carsten Haitzler <ras...@rasterman.com>
AuthorDate: Mon May 16 14:02:06 2022 +0100

    eet - add eet_sync_sync() that syncs data to disk and fdatasyncs it
    
    this ensures that if eet_sync_sync() returns that all data has been
    synced to disk (as best possible with fdatasync()).
    
    @feat
---
 src/lib/eet/Eet.h     | 17 +++++++++++++++++
 src/lib/eet/eet_lib.c | 34 ++++++++++++++++++++++++++++++----
 2 files changed, 47 insertions(+), 4 deletions(-)

diff --git a/src/lib/eet/Eet.h b/src/lib/eet/Eet.h
index 455042fc0c..5bbaf8b9c3 100644
--- a/src/lib/eet/Eet.h
+++ b/src/lib/eet/Eet.h
@@ -691,6 +691,23 @@ eet_close(Eet_File *ef);
 EAPI Eet_Error
 eet_sync(Eet_File *ef);
 
+/**
+ * @ingroup Eet_File_Group
+ * @brief does exactly what eet_xunc() does but also fsyncs file data
+ * @param ef A valid eet file handle.
+ * @return An eet error identifier.
+ *
+ * This function does everything eet_xunc() does with one addition - it
+ * ensures data is written to/synced to disk (as best is possible) by
+ * calling fdatasync() on the file before writes are all queued/done.
+ *
+ * If the eet file handle is not valid nothing will be done.
+ *
+ * @since 1.27
+ */
+EAPI Eet_Error
+eet_sync_sync(Eet_File *ef);
+
 /**
  * @ingroup Eet_File_Group
  * @brief Returns a handle to the shared string dictionary of the Eet file
diff --git a/src/lib/eet/eet_lib.c b/src/lib/eet/eet_lib.c
index 0ed786e1d7..3a1e885443 100644
--- a/src/lib/eet/eet_lib.c
+++ b/src/lib/eet/eet_lib.c
@@ -71,7 +71,7 @@ static Eet_Error
 eet_flush(Eet_File *ef);
 #endif /* if 0 */
 static Eet_Error
- eet_flush2(Eet_File *ef);
+ eet_flush2(Eet_File *ef, Eina_Bool sync);
 static Eet_File_Node *
  find_node_by_name(Eet_File  *ef,
                   const char *name);
@@ -288,7 +288,7 @@ eet_string_match(const char *s1,
 
 /* flush out writes to a v2 eet file */
 static Eet_Error
-eet_flush2(Eet_File *ef)
+eet_flush2(Eet_File *ef, Eina_Bool sync)
 {
    Eet_File_Node *efn;
    FILE *fp;
@@ -509,6 +509,9 @@ eet_flush2(Eet_File *ef)
    /* no more writes pending */
    ef->writes_pending = 0;
 
+#ifndef _WIN32
+   if (sync) fdatasync(fileno(fp));
+#endif
    fclose(fp);
 
    return EET_ERROR_NONE;
@@ -664,7 +667,30 @@ eet_sync(Eet_File *ef)
 
    LOCK_FILE(ef);
 
-   ret = eet_flush2(ef);
+   ret = eet_flush2(ef, EINA_FALSE);
+
+   UNLOCK_FILE(ef);
+   return ret;
+}
+
+EAPI Eet_Error
+eet_sync_sync(Eet_File *ef)
+{
+   Eet_Error ret;
+
+   if (eet_check_pointer(ef))
+     return EET_ERROR_BAD_OBJECT;
+
+   if ((ef->mode != EET_FILE_MODE_WRITE) &&
+       (ef->mode != EET_FILE_MODE_READ_WRITE))
+     return EET_ERROR_NOT_WRITABLE;
+
+   if (!ef->writes_pending)
+     return EET_ERROR_NONE;
+
+   LOCK_FILE(ef);
+
+   ret = eet_flush2(ef, EINA_TRUE);
 
    UNLOCK_FILE(ef);
    return ret;
@@ -1283,7 +1309,7 @@ eet_internal_close(Eet_File *ef,
          goto on_error;
      }
 
-   err = eet_flush2(ef);
+   err = eet_flush2(ef, EINA_FALSE);
 
    eet_identity_unref(ef->key);
    ef->key = NULL;

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.

Reply via email to