From 38e23bb0eb71e160fdfa829398a46ec3db01d7aa Mon Sep 17 00:00:00 2001 From: Nat Goodspeed Date: Wed, 18 Apr 2012 15:43:34 -0400 Subject: IQA-463: Make LLProcess call apr_procattr_inherit_set() extension. On Windows, Bad Things happen when apr_proc_create() is allowed to pass TRUE to CreateProcess(bInheritHandles). For instance, the open handle for a new installer executable file being downloaded by the background updater gets inadvertently passed to a couple slplugin.exe instances. When the viewer finishes downloading, closes the file and tries to remove it, Windows balks because the file is still open by another process. Require an apr_suite package that includes the new Linden apr_procattr_inherit_set() extension, and call it to turn off CreateProcess(bInheritHandles). --- autobuild.xml | 12 ++++++------ indra/llcommon/llprocess.cpp | 35 +++++++++++++++++++++++++---------- 2 files changed, 31 insertions(+), 16 deletions(-) diff --git a/autobuild.xml b/autobuild.xml index 19913bf8de..4288b60c30 100644 --- a/autobuild.xml +++ b/autobuild.xml @@ -90,9 +90,9 @@ archive hash - 02eb2d32f4013e23eb0bc2cd1b7f9b82 + 1ac038723ed702a5ad0db924dfe0fe1b url - http://automated-builds-secondlife-com.s3.amazonaws.com/hg/repo/3p-apr/rev/251231/arch/Darwin/installer/apr_suite-1.4.5-darwin-20120314.tar.bz2 + http://automated-builds-secondlife-com.s3.amazonaws.com/hg/repo/3p-apr/rev/254105/arch/Darwin/installer/apr_suite-1.4.5-darwin-20120418.tar.bz2 name darwin @@ -102,9 +102,9 @@ archive hash - 4ade1434e263cbb85a424e7dd35b8025 + c60ace3d6c593d95247bd58496d7c557 url - http://automated-builds-secondlife-com.s3.amazonaws.com/hg/repo/3p-apr/rev/251231/arch/Linux/installer/apr_suite-1.4.5-linux-20120314.tar.bz2 + http://automated-builds-secondlife-com.s3.amazonaws.com/hg/repo/3p-apr/rev/254105/arch/Linux/installer/apr_suite-1.4.5-linux-20120418.tar.bz2 name linux @@ -114,9 +114,9 @@ archive hash - 6a2f05e8ddf01036aada46377295887f + d353e31abcefb554379abdec0ac41ff3 url - http://automated-builds-secondlife-com.s3.amazonaws.com/hg/repo/3p-apr/rev/251231/arch/CYGWIN/installer/apr_suite-1.4.5-windows-20120314.tar.bz2 + http://automated-builds-secondlife-com.s3.amazonaws.com/hg/repo/3p-apr/rev/254105/arch/CYGWIN/installer/apr_suite-1.4.5-windows-20120418.tar.bz2 name windows diff --git a/indra/llcommon/llprocess.cpp b/indra/llcommon/llprocess.cpp index d4786035ce..e96b328365 100644 --- a/indra/llcommon/llprocess.cpp +++ b/indra/llcommon/llprocess.cpp @@ -535,6 +535,24 @@ LLProcess::LLProcess(const LLSDOrParams& params): apr_procattr_t *procattr = NULL; chkapr(apr_procattr_create(&procattr, gAPRPoolp)); +#if ! defined(APR_HAS_PROCATTR_INHERIT_SET) + // Our special preprocessor symbol isn't even defined -- wrong APR + LL_WARNS("LLProcess") << "This version of APR lacks Linden apr_procattr_inherit_set() extension" << LL_ENDL; +#elif ! APR_HAS_PROCATTR_INHERIT_SET + // Symbol is defined, but to 0: expect apr_procattr_inherit_set() to + // return APR_ENOTIMPL. + LL_DEBUGS("LLProcess") << "apr_procattr_inherit_set() not supported on this platform" << LL_ENDL; +#else // APR_HAS_PROCATTR_INHERIT_SET nonzero + // As of 2012-04-17, the original Windows implementation of + // apr_proc_create() unconditionally passes TRUE for bInheritHandles. That + // seems to assume that all files are opened by APR so you can + // individually control whether each is inherited by a child process. But + // we've been burned by having surprising open file handles inherited by + // our child processes. Turn that OFF for us! + LL_DEBUGS("LLProcess") << "Setting apr_procattr_inherit_set(0)" << LL_ENDL; + ll_apr_warn_status(apr_procattr_inherit_set(procattr, 0)); +#endif + // For which of stdin, stdout, stderr should we create a pipe to the // child? In the viewer, there are only a couple viable // apr_procattr_io_set() alternatives: inherit the viewer's own stdxxx @@ -607,17 +625,14 @@ LLProcess::LLProcess(const LLSDOrParams& params): if (params.autokill) { -#if defined(APR_HAS_PROCATTR_AUTOKILL_SET) - apr_status_t ok = apr_procattr_autokill_set(procattr, 1); -# if LL_WINDOWS - // As of 2012-02-02, we only expect this to be implemented on Windows. - // Avoid spamming the log with warnings we fully expect. - ll_apr_warn_status(ok); -#else // ! LL_WINDOWS - (void)ok; // suppress 'unused' warning -# endif // ! LL_WINDOWS -#else +#if ! defined(APR_HAS_PROCATTR_AUTOKILL_SET) + // Our special preprocessor symbol isn't even defined -- wrong APR LL_WARNS("LLProcess") << "This version of APR lacks Linden apr_procattr_autokill_set() extension" << LL_ENDL; +#elif ! APR_HAS_PROCATTR_AUTOKILL_SET + // Symbol is defined, but to 0: expect apr_procattr_autokill_set() to + // return APR_ENOTIMPL. +#else // APR_HAS_PROCATTR_AUTOKILL_SET nonzero + ll_apr_warn_status(apr_procattr_autokill_set(procattr, 1)); #endif } -- cgit v1.2.3