summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorwrowe <wrowe@13f79535-47bb-0310-9956-ffa450edef68>2007-08-28 04:43:39 +0000
committerwrowe <wrowe@13f79535-47bb-0310-9956-ffa450edef68>2007-08-28 04:43:39 +0000
commit8c9b175a483cf93dd12258b7378578e62c05d52e (patch)
tree9f2791f21f19ac6aa47e02b05390703f3c3b9956 /include
parent4d3a2a43b28f6ecb4cc90abd09bc036577390705 (diff)
downloadlibapr-8c9b175a483cf93dd12258b7378578e62c05d52e.tar.gz
Solve win32 inherited pipe leaks by leveraging OS2 port's solution.
Mutex the pipe manipulation on WinNT+++ alone (not WinCE, nor 9x) so that we toggle the inherited state of the stdin/out/err pipes. This is only possible on NT, because in CE/9x it would involve replacing the pipe handles all over the place as there is no toggle. This CRITICAL_SECTION pipe is incredibly fast in the mainline case, and only introduces contention in the threaded server after startup (for cgi, etc). Not unlike an in-process cgid. So, leave WinCE alone for now, since it doesn't follow the stdio model, and leave Win9x alone for good, as nearly abandoned. Backport: r569882 (+r569890) git-svn-id: http://svn.apache.org/repos/asf/apr/apr/branches/0.9.x@570304 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'include')
-rw-r--r--include/arch/win32/apr_arch_inherit.h98
-rw-r--r--include/arch/win32/apr_arch_threadproc.h2
2 files changed, 64 insertions, 36 deletions
diff --git a/include/arch/win32/apr_arch_inherit.h b/include/arch/win32/apr_arch_inherit.h
index be47f870f..88e6f0de7 100644
--- a/include/arch/win32/apr_arch_inherit.h
+++ b/include/arch/win32/apr_arch_inherit.h
@@ -21,43 +21,19 @@
#define APR_INHERIT (1 << 24) /* Must not conflict with other bits */
-#if defined(_WIN32_WCE)
-#define APR_IMPLEMENT_INHERIT_SET(name, flag, pool, cleanup) \
-APR_DECLARE(apr_status_t) apr_##name##_inherit_set(apr_##name##_t *the##name) \
-{ \
- HANDLE temp, hproc = GetCurrentProcess(); \
- if (!DuplicateHandle(hproc, the##name->filehand, \
- hproc, &temp, 0, TRUE, \
- DUPLICATE_SAME_ACCESS)) \
- return apr_get_os_error(); \
- CloseHandle(the##name->filehand); \
- the##name->filehand = temp; \
- return APR_SUCCESS; \
-}
+#if APR_HAS_UNICODE_FS && APR_HAS_ANSI_FS
+/* !defined(_WIN32_WCE) is implicit here */
-#define APR_IMPLEMENT_INHERIT_UNSET(name, flag, pool, cleanup) \
-APR_DECLARE(apr_status_t) apr_##name##_inherit_unset(apr_##name##_t *the##name)\
-{ \
- HANDLE temp, hproc = GetCurrentProcess(); \
- if (!DuplicateHandle(hproc, the##name->filehand, \
- hproc, &temp, 0, FALSE, \
- DUPLICATE_SAME_ACCESS)) \
- return apr_get_os_error(); \
- CloseHandle(the##name->filehand); \
- the##name->filehand = temp; \
- return APR_SUCCESS; \
-}
-#else
#define APR_IMPLEMENT_INHERIT_SET(name, flag, pool, cleanup) \
APR_DECLARE(apr_status_t) apr_##name##_inherit_set(apr_##name##_t *the##name) \
{ \
IF_WIN_OS_IS_UNICODE \
{ \
- if (!SetHandleInformation(the##name->filehand, \
- HANDLE_FLAG_INHERIT, \
- HANDLE_FLAG_INHERIT)) \
- return apr_get_os_error(); \
- } \
+/* if (!SetHandleInformation(the##name->filehand, \
+ * HANDLE_FLAG_INHERIT, \
+ * HANDLE_FLAG_INHERIT)) \
+ * return apr_get_os_error(); \
+ */ } \
ELSE_WIN_OS_IS_ANSI \
{ \
HANDLE temp, hproc = GetCurrentProcess(); \
@@ -81,10 +57,10 @@ APR_DECLARE(apr_status_t) apr_##name##_inherit_unset(apr_##name##_t *the##name)\
{ \
IF_WIN_OS_IS_UNICODE \
{ \
- if (!SetHandleInformation(the##name->filehand, \
- HANDLE_FLAG_INHERIT, 0)) \
- return apr_get_os_error(); \
- } \
+/* if (!SetHandleInformation(the##name->filehand, \
+ * HANDLE_FLAG_INHERIT, 0)) \
+ * return apr_get_os_error(); \
+ */ } \
ELSE_WIN_OS_IS_ANSI \
{ \
HANDLE temp, hproc = GetCurrentProcess(); \
@@ -102,6 +78,56 @@ APR_DECLARE(void) apr_##name##_unset_inherit(apr_##name##_t *the##name) \
{ \
apr_##name##_inherit_unset(the##name); \
}
-#endif
+
+#elif APR_HAS_ANSI_FS || defined(_WIN32_WCE)
+
+#define APR_IMPLEMENT_INHERIT_SET(name, flag, pool, cleanup) \
+APR_DECLARE(apr_status_t) apr_##name##_inherit_set(apr_##name##_t *the##name) \
+{ \
+ HANDLE temp, hproc = GetCurrentProcess(); \
+ if (!DuplicateHandle(hproc, the##name->filehand, \
+ hproc, &temp, 0, TRUE, \
+ DUPLICATE_SAME_ACCESS)) \
+ return apr_get_os_error(); \
+ CloseHandle(the##name->filehand); \
+ the##name->filehand = temp; \
+ return APR_SUCCESS; \
+}
+
+#define APR_IMPLEMENT_INHERIT_UNSET(name, flag, pool, cleanup) \
+APR_DECLARE(apr_status_t) apr_##name##_inherit_unset(apr_##name##_t *the##name)\
+{ \
+ HANDLE temp, hproc = GetCurrentProcess(); \
+ if (!DuplicateHandle(hproc, the##name->filehand, \
+ hproc, &temp, 0, FALSE, \
+ DUPLICATE_SAME_ACCESS)) \
+ return apr_get_os_error(); \
+ CloseHandle(the##name->filehand); \
+ the##name->filehand = temp; \
+ return APR_SUCCESS; \
+}
+
+#else /* APR_HAS_UNICODE_FS && !APR_HAS_ANSI_FS && !defined(_WIN32_WCE) */
+
+#define APR_IMPLEMENT_INHERIT_SET(name, flag, pool, cleanup) \
+APR_DECLARE(apr_status_t) apr_##name##_inherit_set(apr_##name##_t *the##name) \
+{ \
+/* if (!SetHandleInformation(the##name->filehand, \
+ * HANDLE_FLAG_INHERIT, \
+ * HANDLE_FLAG_INHERIT)) \
+ * return apr_get_os_error(); \
+ */ return APR_SUCCESS; \
+}
+
+#define APR_IMPLEMENT_INHERIT_UNSET(name, flag, pool, cleanup) \
+APR_DECLARE(apr_status_t) apr_##name##_inherit_unset(apr_##name##_t *the##name)\
+{ \
+/* if (!SetHandleInformation(the##name->filehand, \
+ * HANDLE_FLAG_INHERIT, 0)) \
+ * return apr_get_os_error(); \
+ */ return APR_SUCCESS; \
+}
+
+#endif /* defined(APR_HAS_UNICODE_FS) */
#endif /* ! INHERIT_H */
diff --git a/include/arch/win32/apr_arch_threadproc.h b/include/arch/win32/apr_arch_threadproc.h
index 268fde464..d5e43fd10 100644
--- a/include/arch/win32/apr_arch_threadproc.h
+++ b/include/arch/win32/apr_arch_threadproc.h
@@ -63,5 +63,7 @@ struct apr_thread_once_t {
long value;
};
+extern apr_status_t apr_threadproc_init(apr_pool_t *pool);
+
#endif /* ! THREAD_PROC_H */