jerenkrantz 2002/07/16 10:55:02
Modified: . CHANGES
file_io/os2 open.c
file_io/unix open.c
file_io/win32 open.c
Log:
Add APR_BUFFERED support to apr_file_os_put() calls.
Revision Changes Path
1.307 +2 -0 apr/CHANGES
Index: CHANGES
===================================================================
RCS file: /home/cvs/apr/CHANGES,v
retrieving revision 1.306
retrieving revision 1.307
diff -u -r1.306 -r1.307
--- CHANGES 15 Jul 2002 06:50:07 -0000 1.306
+++ CHANGES 16 Jul 2002 17:55:01 -0000 1.307
@@ -1,5 +1,7 @@
Changes with APR b1
+ *) Add APR_BUFFERED support to apr_os_file_put(). [Justin Erenkrantz]
+
*) Fix misinterpretation of timeout for select() on Win32/Netware.
Identified by [TANAKA Koichi <[EMAIL PROTECTED]>]
1.53 +11 -1 apr/file_io/os2/open.c
Index: open.c
===================================================================
RCS file: /home/cvs/apr/file_io/os2/open.c,v
retrieving revision 1.52
retrieving revision 1.53
diff -u -r1.52 -r1.53
--- open.c 8 Jun 2002 22:32:11 -0000 1.52
+++ open.c 16 Jul 2002 17:55:01 -0000 1.53
@@ -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;
}
1.98 +15 -4 apr/file_io/unix/open.c
Index: open.c
===================================================================
RCS file: /home/cvs/apr/file_io/unix/open.c,v
retrieving revision 1.97
retrieving revision 1.98
diff -u -r1.97 -r1.98
--- open.c 8 Jun 2002 22:32:11 -0000 1.97
+++ open.c 16 Jul 2002 17:55:01 -0000 1.98
@@ -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;
}
1.106 +16 -0 apr/file_io/win32/open.c
Index: open.c
===================================================================
RCS file: /home/cvs/apr/file_io/win32/open.c,v
retrieving revision 1.105
retrieving revision 1.106
diff -u -r1.105 -r1.106
--- open.c 8 Jun 2002 22:32:11 -0000 1.105
+++ open.c 16 Jul 2002 17:55:01 -0000 1.106
@@ -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?