wrowe 01/07/18 12:12:41
Modified: file_io/os2 open.c
file_io/unix filedup.c open.c
file_io/win32 open.c
include apr_file_io.h
Log:
Set up the inherit mechanics to drop the APR_INHERIT flag.
Revision Changes Path
1.43 +6 -2 apr/file_io/os2/open.c
Index: open.c
===================================================================
RCS file: /home/cvs/apr/file_io/os2/open.c,v
retrieving revision 1.42
retrieving revision 1.43
diff -u -r1.42 -r1.43
--- open.c 2001/06/07 14:32:10 1.42
+++ open.c 2001/07/18 19:12:40 1.43
@@ -143,8 +143,7 @@
dafile->dataRead = 0;
dafile->direction = 0;
dafile->pipe = FALSE;
-
- apr_pool_cleanup_register(dafile->cntxt, dafile, apr_file_cleanup,
apr_pool_cleanup_null);
+ apr_pool_cleanup_register(dafile->cntxt, dafile, apr_file_cleanup,
apr_file_cleanup);
return APR_SUCCESS;
}
@@ -265,3 +264,8 @@
}
APR_POOL_IMPLEMENT_ACCESSOR_X(file, cntxt);
+
+APR_IMPLEMENT_SET_INHERIT(socket, inherit, cntxt, socket_cleanup)
+
+APR_IMPLEMENT_UNSET_INHERIT(socket, inherit, cntxt, socket_cleanup)
+
1.33 +7 -5 apr/file_io/unix/filedup.c
Index: filedup.c
===================================================================
RCS file: /home/cvs/apr/file_io/unix/filedup.c,v
retrieving revision 1.32
retrieving revision 1.33
diff -u -r1.32 -r1.33
--- filedup.c 2001/07/16 20:51:43 1.32
+++ filedup.c 2001/07/18 19:12:41 1.33
@@ -85,12 +85,14 @@
#endif
(*new_file)->buffer = apr_palloc(p, APR_FILE_BUFSIZE);
}
- (*new_file)->blocking = old_file->blocking; /* this is the way dup()
works */
- (*new_file)->flags = old_file->flags;
+ /* this is the way dup() works */
+ (*new_file)->blocking = old_file->blocking;
+ /* apr_file_dup() clears the inherit attribute, user must call
+ * apr_file_set_inherit() again on the dupped handle, as necessary.
+ */
+ (*new_file)->flags = old_file->flags & ~APR_INHERIT;
apr_pool_cleanup_register((*new_file)->cntxt, (void *)(*new_file),
- apr_unix_file_cleanup,
- ((*new_file)->flags & APR_INHERIT)
- ? apr_pool_cleanup_null :
apr_unix_file_cleanup);
+ apr_unix_file_cleanup, apr_unix_file_cleanup);
return APR_SUCCESS;
}
1.82 +1 -5 apr/file_io/unix/open.c
Index: open.c
===================================================================
RCS file: /home/cvs/apr/file_io/unix/open.c,v
retrieving revision 1.81
retrieving revision 1.82
diff -u -r1.81 -r1.82
--- open.c 2001/07/16 23:35:14 1.81
+++ open.c 2001/07/18 19:12:41 1.82
@@ -168,10 +168,7 @@
(*new)->dataRead = 0;
(*new)->direction = 0;
apr_pool_cleanup_register((*new)->cntxt, (void *)(*new),
- apr_unix_file_cleanup,
- ((*new)->flags & APR_INHERIT)
- ? apr_pool_cleanup_null
- : apr_unix_file_cleanup);
+ apr_unix_file_cleanup, apr_unix_file_cleanup);
return APR_SUCCESS;
}
@@ -227,7 +224,6 @@
/* buffer already NULL;
* don't get a lock (only for buffered files)
*/
- (*file)->flags = APR_INHERIT;
return APR_SUCCESS;
}
1.79 +10 -9 apr/file_io/win32/open.c
Index: open.c
===================================================================
RCS file: /home/cvs/apr/file_io/win32/open.c,v
retrieving revision 1.78
retrieving revision 1.79
diff -u -r1.78 -r1.79
--- open.c 2001/07/16 20:46:23 1.78
+++ open.c 2001/07/18 19:12:41 1.79
@@ -173,7 +173,6 @@
apr_int32_t flag, apr_fileperms_t perm,
apr_pool_t *cont)
{
- SECURITY_ATTRIBUTES sa, *psa = NULL;
HANDLE handle = INVALID_HANDLE_VALUE;
DWORD oflags = 0;
DWORD createflags = 0;
@@ -233,12 +232,6 @@
*/
attributes |= FILE_FLAG_OVERLAPPED;
}
- if (flag & APR_INHERIT) {
- sa.nLength = sizeof(sa);
- sa.bInheritHandle = TRUE;
- sa.lpSecurityDescriptor = NULL;
- psa = &sa;
- }
#if APR_HAS_UNICODE_FS
if (os_level >= APR_WIN_NT) {
@@ -247,12 +240,12 @@
/ sizeof(apr_wchar_t), fname))
return rv;
handle = CreateFileW(wfname, oflags, sharemode,
- psa, createflags, attributes, 0);
+ NULL, createflags, attributes, 0);
}
else
#endif
handle = CreateFileA(fname, oflags, sharemode,
- psa, createflags, attributes, 0);
+ NULL, createflags, attributes, 0);
if (handle == INVALID_HANDLE_VALUE) {
return apr_get_os_error();
@@ -460,3 +453,11 @@
}
APR_POOL_IMPLEMENT_ACCESSOR_X(file, cntxt);
+
+APR_DECLARE_SET_INHERIT(file) {
+ return;
+}
+
+APR_DECLARE_UNSET_INHERIT(file) {
+ return;
+}
\ No newline at end of file
1.105 +0 -14 apr/include/apr_file_io.h
Index: apr_file_io.h
===================================================================
RCS file: /home/cvs/apr/include/apr_file_io.h,v
retrieving revision 1.104
retrieving revision 1.105
diff -u -r1.104 -r1.105
--- apr_file_io.h 2001/07/16 20:44:17 1.104
+++ apr_file_io.h 2001/07/18 19:12:41 1.105
@@ -90,12 +90,6 @@
#define APR_SHARELOCK 1024 /* Platform dependent support for higher
level locked read/write access to
support
writes across process/machines */
-#ifndef APR_INHERIT
-#define APR_INHERIT (2^24) /* Create the file inheritable by the
child
- process. fork()ed implementations
- automatically register a child cleanup
- in the _absense_ of this flag. */
-#endif
/* flags for apr_file_seek */
#define APR_SET SEEK_SET
@@ -148,10 +142,6 @@
* APR_SHARELOCK Platform dependent support for higher
* level locked read/write access to support
* writes across process/machines
- * APR_INHERIT Create the file inheritable by the child
- * processes. fork()ed implementations
- * automatically register a child cleanup
- * in the _absense_ of this flag.
* </PRE>
* @param perm Access permissions for file.
* @param cont The pool to use.
@@ -584,8 +574,6 @@
* Set a file to be inherited by child processes.
* @param file The file to enable inheritance.
* @deffunc void apr_file_set_inherit(apr_file_t *file)
- * @tip Same effect as passing the APR_INHERIT flag to apr_file_open(),
- * but it is far more efficient to pass the correct value in the first place.
*/
APR_DECLARE_SET_INHERIT(file);
@@ -593,8 +581,6 @@
* Unset a file from being inherited by child processes.
* @param file The file to disable inheritance.
* @deffunc void apr_file_unset_inherit(apr_file_t *file)
- * @tip Same effect as omiting the APR_INHERIT flag to apr_file_open(),
- * but it is far more efficient to pass the correct value in the first place.
*/
APR_DECLARE_UNSET_INHERIT(file);