apr-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bo...@apache.org
Subject svn commit: r784633 - in /apr/apr/trunk: CHANGES file_io/os2/readwrite.c file_io/unix/readwrite.c file_io/win32/readwrite.c include/apr_file_io.h
Date Sun, 14 Jun 2009 23:35:13 GMT
Author: bojan
Date: Sun Jun 14 23:35:13 2009
New Revision: 784633

URL: http://svn.apache.org/viewvc?rev=784633&view=rev
Log:
Add apr_file_sync() and apr_file_datasync() calls.

Modified:
    apr/apr/trunk/CHANGES
    apr/apr/trunk/file_io/os2/readwrite.c
    apr/apr/trunk/file_io/unix/readwrite.c
    apr/apr/trunk/file_io/win32/readwrite.c
    apr/apr/trunk/include/apr_file_io.h

Modified: apr/apr/trunk/CHANGES
URL: http://svn.apache.org/viewvc/apr/apr/trunk/CHANGES?rev=784633&r1=784632&r2=784633&view=diff
==============================================================================
--- apr/apr/trunk/CHANGES [utf-8] (original)
+++ apr/apr/trunk/CHANGES [utf-8] Sun Jun 14 23:35:13 2009
@@ -1,6 +1,9 @@
                                                      -*- coding: utf-8 -*-
 Changes for APR 2.0.0
 
+  *) Add apr_file_sync() and apr_file_datasync() calls.
+     [Bojan Smojver]
+
   *) Fix race conditions in initialisation of DBD, DBM and DSO.
      [Bojan Smojver]
 

Modified: apr/apr/trunk/file_io/os2/readwrite.c
URL: http://svn.apache.org/viewvc/apr/apr/trunk/file_io/os2/readwrite.c?rev=784633&r1=784632&r2=784633&view=diff
==============================================================================
--- apr/apr/trunk/file_io/os2/readwrite.c (original)
+++ apr/apr/trunk/file_io/os2/readwrite.c Sun Jun 14 23:35:13 2009
@@ -304,6 +304,15 @@
     }
 }
 
+APR_DECLARE(apr_status_t) apr_file_sync(apr_file_t *thefile)
+{
+    return APR_SUCCESS;
+}
+
+APR_DECLARE(apr_status_t) apr_file_datasync(apr_file_t *thefile)
+{
+    return APR_SUCCESS;
+}
 
 APR_DECLARE(apr_status_t) apr_file_gets(char *str, int len, apr_file_t *thefile)
 {

Modified: apr/apr/trunk/file_io/unix/readwrite.c
URL: http://svn.apache.org/viewvc/apr/apr/trunk/file_io/unix/readwrite.c?rev=784633&r1=784632&r2=784633&view=diff
==============================================================================
--- apr/apr/trunk/file_io/unix/readwrite.c (original)
+++ apr/apr/trunk/file_io/unix/readwrite.c Sun Jun 14 23:35:13 2009
@@ -342,6 +342,54 @@
     return rv;
 }
 
+APR_DECLARE(apr_status_t) apr_file_sync(apr_file_t *thefile)
+{
+    apr_status_t rv = APR_SUCCESS;
+
+    file_lock(thefile);
+
+    if (thefile->buffered) {
+        rv = apr_file_flush_locked(thefile);
+
+        if (rv != APR_SUCCESS) {
+            file_unlock(thefile);
+            return rv;
+        }
+    }
+
+    if (fsync(thefile->filedes)) {
+        rv = apr_get_os_error();
+    }
+
+    file_unlock(thefile);
+
+    return rv;
+}
+
+APR_DECLARE(apr_status_t) apr_file_datasync(apr_file_t *thefile)
+{
+    apr_status_t rv = APR_SUCCESS;
+
+    file_lock(thefile);
+
+    if (thefile->buffered) {
+        rv = apr_file_flush_locked(thefile);
+
+        if (rv != APR_SUCCESS) {
+            file_unlock(thefile);
+            return rv;
+        }
+    }
+
+    if (fdatasync(thefile->filedes)) {
+        rv = apr_get_os_error();
+    }
+
+    file_unlock(thefile);
+
+    return rv;
+}
+
 APR_DECLARE(apr_status_t) apr_file_gets(char *str, int len, apr_file_t *thefile)
 {
     apr_status_t rv = APR_SUCCESS; /* get rid of gcc warning */

Modified: apr/apr/trunk/file_io/win32/readwrite.c
URL: http://svn.apache.org/viewvc/apr/apr/trunk/file_io/win32/readwrite.c?rev=784633&r1=784632&r2=784633&view=diff
==============================================================================
--- apr/apr/trunk/file_io/win32/readwrite.c (original)
+++ apr/apr/trunk/file_io/win32/readwrite.c Sun Jun 14 23:35:13 2009
@@ -516,6 +516,25 @@
     return APR_SUCCESS; 
 }
 
+APR_DECLARE(apr_status_t) apr_file_sync(apr_file_t *thefile){
+    apr_status_t rv;
+
+    rv = apr_file_flush(thefile);
+    if (rv != APR_SUCCESS) {
+        return rv;
+    }
+
+    if (!FlushFileBuffers(thefile->filehand)) {
+        rv = apr_get_os_error();
+    }
+
+    return rv;
+}
+
+APR_DECLARE(apr_status_t) apr_file_datasync(apr_file_t *thefile){
+    return apr_file_sync(thefile);
+}
+
 struct apr_file_printf_data {
     apr_vformatter_buff_t vbuff;
     apr_file_t *fptr;

Modified: apr/apr/trunk/include/apr_file_io.h
URL: http://svn.apache.org/viewvc/apr/apr/trunk/include/apr_file_io.h?rev=784633&r1=784632&r2=784633&view=diff
==============================================================================
--- apr/apr/trunk/include/apr_file_io.h (original)
+++ apr/apr/trunk/include/apr_file_io.h Sun Jun 14 23:35:13 2009
@@ -565,6 +565,18 @@
 APR_DECLARE(apr_status_t) apr_file_flush(apr_file_t *thefile);
 
 /**
+ * Transfer all file modified data and metadata to disk.
+ * @param thefile The file descriptor to sync
+ */
+APR_DECLARE(apr_status_t) apr_file_sync(apr_file_t *thefile);
+
+/**
+ * Transfer all file modified data to disk.
+ * @param thefile The file descriptor to sync
+ */
+APR_DECLARE(apr_status_t) apr_file_datasync(apr_file_t *thefile);
+
+/**
  * Duplicate the specified file descriptor.
  * @param new_file The structure to duplicate into. 
  * @param old_file The file to duplicate.



Mime
View raw message