You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@apr.apache.org by Justin Erenkrantz <je...@apache.org> on 2002/07/13 04:57:45 UTC
[PATCH] Support buffering on apr_os_file_put
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?
Re: [PATCH] Support buffering on apr_os_file_put
Posted by Aaron Bannert <aa...@clove.org>.
On Fri, Jul 12, 2002 at 08:16:03PM -0700, Aaron Bannert wrote:
> On Fri, Jul 12, 2002 at 07:57:45PM -0700, Justin Erenkrantz wrote:
> > 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
>
> Hmm...I would expect stdin to be buffered by default, is this not
> the case? Typically stdin and stdout is buffered, and stderr is
> optionally nonbuffered.
In case it wasn't obvious, +1 to the idea. :)
-aaron
Re: [PATCH] Support buffering on apr_os_file_put
Posted by Aaron Bannert <aa...@clove.org>.
On Fri, Jul 12, 2002 at 07:57:45PM -0700, Justin Erenkrantz wrote:
> 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
Hmm...I would expect stdin to be buffered by default, is this not
the case? Typically stdin and stdout is buffered, and stderr is
optionally nonbuffered.
-aaron