apr-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Justin Erenkrantz <jerenkra...@apache.org>
Subject [PATCH] Support buffering on apr_os_file_put
Date Sat, 13 Jul 2002 02:57:45 GMT
To make a certain functionality of Subversion more efficient (namely
svnadmin load), stdin should be allowed to be buffered.

Would anyone have any problems if I commit this?  

The other question is how to get stdin buffered from the client.  Do
we modify apr_file_open_stdin() to take a flag, or do we have to do a
apr_file_open_stdin(), apr_os_file_get(), apr_os_file_put() with
the buffered flag?  -- justin

Index: file_io/os2/open.c
===================================================================
RCS file: /home/cvs/apr/file_io/os2/open.c,v
retrieving revision 1.52
diff -u -r1.52 open.c
--- file_io/os2/open.c	8 Jun 2002 22:32:11 -0000	1.52
+++ file_io/os2/open.c	13 Jul 2002 02:46:35 -0000
@@ -224,10 +224,20 @@
     (*file)->pool = pool;
     (*file)->filedes = *dafile;
     (*file)->isopen = TRUE;
-    (*file)->buffered = FALSE;
     (*file)->eof_hit = FALSE;
     (*file)->flags = flags;
     (*file)->pipe = FALSE;
+    (*file)->buffered = (flags & APR_BUFFERED) > 0;
+
+    if ((*file)->buffered) {
+        apr_status_t rv;
+
+        (*file)->buffer = apr_palloc(pool, APR_FILE_BUFSIZE);
+        rv = apr_thread_mutex_create(&(*file)->mutex, 0, pool);
+
+        if (rv)
+            return rv;
+    }
     return APR_SUCCESS;
 }    
 
Index: file_io/unix/open.c
===================================================================
RCS file: /home/cvs/apr/file_io/unix/open.c,v
retrieving revision 1.97
diff -u -r1.97 open.c
--- file_io/unix/open.c	8 Jun 2002 22:32:11 -0000	1.97
+++ file_io/unix/open.c	13 Jul 2002 02:46:35 -0000
@@ -228,15 +228,26 @@
     (*file) = apr_pcalloc(pool, sizeof(apr_file_t));
     (*file)->pool = pool;
     (*file)->eof_hit = 0;
-    (*file)->buffered = 0;
     (*file)->blocking = BLK_UNKNOWN; /* in case it is a pipe */
     (*file)->timeout = -1;
     (*file)->ungetchar = -1; /* no char avail */
     (*file)->filedes = *dafile;
     (*file)->flags = flags;
-    /* buffer already NULL; 
-     * don't get a lock (only for buffered files) 
-     */
+    (*file)->buffered = (flags & APR_BUFFERED) > 0;
+
+    if ((*file)->buffered) {
+        (*file)->buffer = apr_palloc(pool, APR_FILE_BUFSIZE);
+#if APR_HAS_THREADS
+        if ((*file)->flags & APR_XTHREAD) {
+            apr_status_t rv;
+            rv = apr_thread_mutex_create(&((*file)->thlock),
+                                         APR_THREAD_MUTEX_DEFAULT, pool);
+            if (rv) {
+                return rv;
+            }
+        }
+#endif
+    }
     return APR_SUCCESS;
 }    
 
Index: file_io/win32/open.c
===================================================================
RCS file: /home/cvs/apr/file_io/win32/open.c,v
retrieving revision 1.105
diff -u -r1.105 open.c
--- file_io/win32/open.c	8 Jun 2002 22:32:11 -0000	1.105
+++ file_io/win32/open.c	13 Jul 2002 02:47:31 -0000
@@ -524,6 +524,22 @@
     if (flags & APR_APPEND)
         (*file)->append = 1;
 
+    if (flags & APR_BUFFERED) {
+        apr_status_t rv;
+
+        (*file)->buffered = 1;
+        (*file)->buffer = apr_palloc(pool, APR_FILE_BUFSIZE);
+        rv = apr_thread_mutex_create(&(*file)->mutex, APR_THREAD_MUTEX_DEFAULT,
+                                     pool);
+
+        if (rv) {
+            if (file_cleanup(*new) == APR_SUCCESS) {
+                apr_pool_cleanup_kill(pool, *file, file_cleanup);
+            }
+            return rv;
+        }
+    }
+
     /* XXX... we pcalloc above so all others are zeroed.
      * Should we be testing if thefile is a handle to 
      * a PIPE and set up the mechanics appropriately?

Mime
View raw message