apr-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bo...@apache.org
Subject svn commit: r785024 - in /apr/apr/branches/1.4.x: ./ CHANGES file_io/os2/readwrite.c file_io/unix/readwrite.c file_io/win32/readwrite.c include/apr_file_io.h
Date Mon, 15 Jun 2009 23:23:33 GMT
Author: bojan
Date: Mon Jun 15 23:23:33 2009
New Revision: 785024

URL: http://svn.apache.org/viewvc?rev=785024&view=rev
Log:
Backport r784633 and r784773 from the trunk.
Add apr_file_sync() and apr_file_datasync() calls.
Right now OS/2 file sync functions are not implemented.

Modified:
    apr/apr/branches/1.4.x/   (props changed)
    apr/apr/branches/1.4.x/CHANGES
    apr/apr/branches/1.4.x/file_io/os2/readwrite.c
    apr/apr/branches/1.4.x/file_io/unix/readwrite.c
    apr/apr/branches/1.4.x/file_io/win32/readwrite.c
    apr/apr/branches/1.4.x/include/apr_file_io.h

Propchange: apr/apr/branches/1.4.x/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Mon Jun 15 23:23:33 2009
@@ -1 +1 @@
-/apr/apr/trunk:733052,747990,748361,748371,748565,748888,748988,749810,782838,783398,783958
+/apr/apr/trunk:733052,747990,748361,748371,748565,748888,748988,749810,782838,783398,783958,784633,784773

Modified: apr/apr/branches/1.4.x/CHANGES
URL: http://svn.apache.org/viewvc/apr/apr/branches/1.4.x/CHANGES?rev=785024&r1=785023&r2=785024&view=diff
==============================================================================
--- apr/apr/branches/1.4.x/CHANGES [utf-8] (original)
+++ apr/apr/branches/1.4.x/CHANGES [utf-8] Mon Jun 15 23:23:33 2009
@@ -1,6 +1,9 @@
                                                      -*- coding: utf-8 -*-
 Changes for APR 1.4.0
 
+  *) Add apr_file_sync() and apr_file_datasync() calls.
+     [Bojan Smojver]
+
   *) Set CLOEXEC flags where appropriate. Either use new O_CLOEXEC flag and
      associated functions, such as dup3(), accept4(), epoll_create1() etc.,
      or simply set CLOEXEC flag using fcntl().  PR 46425.  [Stefan Fritsch

Modified: apr/apr/branches/1.4.x/file_io/os2/readwrite.c
URL: http://svn.apache.org/viewvc/apr/apr/branches/1.4.x/file_io/os2/readwrite.c?rev=785024&r1=785023&r2=785024&view=diff
==============================================================================
--- apr/apr/branches/1.4.x/file_io/os2/readwrite.c (original)
+++ apr/apr/branches/1.4.x/file_io/os2/readwrite.c Mon Jun 15 23:23:33 2009
@@ -304,6 +304,15 @@
     }
 }
 
+APR_DECLARE(apr_status_t) apr_file_sync(apr_file_t *thefile)
+{
+    return APR_ENOTIMPL;
+}
+
+APR_DECLARE(apr_status_t) apr_file_datasync(apr_file_t *thefile)
+{
+    return APR_ENOTIMPL;
+}
 
 APR_DECLARE(apr_status_t) apr_file_gets(char *str, int len, apr_file_t *thefile)
 {

Modified: apr/apr/branches/1.4.x/file_io/unix/readwrite.c
URL: http://svn.apache.org/viewvc/apr/apr/branches/1.4.x/file_io/unix/readwrite.c?rev=785024&r1=785023&r2=785024&view=diff
==============================================================================
--- apr/apr/branches/1.4.x/file_io/unix/readwrite.c (original)
+++ apr/apr/branches/1.4.x/file_io/unix/readwrite.c Mon Jun 15 23:23:33 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/branches/1.4.x/file_io/win32/readwrite.c
URL: http://svn.apache.org/viewvc/apr/apr/branches/1.4.x/file_io/win32/readwrite.c?rev=785024&r1=785023&r2=785024&view=diff
==============================================================================
--- apr/apr/branches/1.4.x/file_io/win32/readwrite.c (original)
+++ apr/apr/branches/1.4.x/file_io/win32/readwrite.c Mon Jun 15 23:23:33 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/branches/1.4.x/include/apr_file_io.h
URL: http://svn.apache.org/viewvc/apr/apr/branches/1.4.x/include/apr_file_io.h?rev=785024&r1=785023&r2=785024&view=diff
==============================================================================
--- apr/apr/branches/1.4.x/include/apr_file_io.h (original)
+++ apr/apr/branches/1.4.x/include/apr_file_io.h Mon Jun 15 23:23:33 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