Kaydet (Commit) 4bacf58f authored tarafından Stephan Bergmann's avatar Stephan Bergmann

tdf#95843: Wait for fire_glxtest_process also in --headless mode

Discussed with mmeeks on IRC that fire_glxtest_process is probably called as
early as possible so that its reuslt is ready by the time it is needed in the
non-headless case.  So best fix for headless is probably to just wait for the
sub-process at an opportune point, instead of redesigning the whole mess so that
fire_glxtest_process would only be called once its result is actually needed.

Change-Id: I4ea9c9d54b83c9695a3b72317e68fed0c410da0e
Reviewed-on: https://gerrit.libreoffice.org/53154Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarStephan Bergmann <sbergman@redhat.com>
üst a1ad6ee0
...@@ -183,6 +183,7 @@ OUString ReplaceStringHookProc(const OUString& rStr); ...@@ -183,6 +183,7 @@ OUString ReplaceStringHookProc(const OUString& rStr);
#if defined( UNX ) && !defined MACOSX && !defined IOS && !defined ANDROID && !defined LIBO_HEADLESS #if defined( UNX ) && !defined MACOSX && !defined IOS && !defined ANDROID && !defined LIBO_HEADLESS
bool fire_glxtest_process(); bool fire_glxtest_process();
void reap_glxtest_process();
#endif #endif
#endif // INCLUDED_DESKTOP_INC_APP_HXX #endif // INCLUDED_DESKTOP_INC_APP_HXX
......
...@@ -1587,6 +1587,15 @@ int Desktop::Main() ...@@ -1587,6 +1587,15 @@ int Desktop::Main()
CheckOpenCLCompute(xDesktop); CheckOpenCLCompute(xDesktop);
#endif #endif
// In headless mode, reap the process started by fire_glxtest_process() early in soffice_main
// (desktop/source/app/sofficemain.cxx), in a code block that needs to be covered by the same
// #if condition as this code block:
#if defined( UNX ) && !defined MACOSX && !defined IOS && !defined ANDROID && !defined(LIBO_HEADLESS) && HAVE_FEATURE_OPENGL
if (rCmdLineArgs.IsHeadless()) {
reap_glxtest_process();
}
#endif
// Release solar mutex just before we wait for our client to connect // Release solar mutex just before we wait for our client to connect
{ {
SolarMutexReleaser aReleaser; SolarMutexReleaser aReleaser;
......
...@@ -125,6 +125,10 @@ extern "C" int DESKTOP_DLLPUBLIC soffice_main() ...@@ -125,6 +125,10 @@ extern "C" int DESKTOP_DLLPUBLIC soffice_main()
#if defined( UNX ) && !defined MACOSX && !defined IOS && !defined ANDROID && !defined(LIBO_HEADLESS) && HAVE_FEATURE_OPENGL #if defined( UNX ) && !defined MACOSX && !defined IOS && !defined ANDROID && !defined(LIBO_HEADLESS) && HAVE_FEATURE_OPENGL
/* Run test for OpenGL support in own process to avoid crash with broken /* Run test for OpenGL support in own process to avoid crash with broken
* OpenGL drivers. Start process as early as possible. * OpenGL drivers. Start process as early as possible.
* In non-headless mode, the process will be reaped in X11OpenGLDeviceInfo::GetData
* (vcl/opengl/x11/X11DeviceInfo.cxx). In headless mode, the process will be reaped late in
* Desktop::Main (desktop/source/app/app.cxx), in a code block that needs to be covered by the
* same #if condition as this code block.
*/ */
bool bSuccess = fire_glxtest_process(); bool bSuccess = fire_glxtest_process();
SAL_WARN_IF(!bSuccess, "desktop.opengl", "problems with glxtest"); SAL_WARN_IF(!bSuccess, "desktop.opengl", "problems with glxtest");
......
...@@ -18,6 +18,8 @@ VCL_DLLPUBLIC pid_t* getGlxPid(); ...@@ -18,6 +18,8 @@ VCL_DLLPUBLIC pid_t* getGlxPid();
bool fire_glxtest_process(); bool fire_glxtest_process();
void reap_glxtest_process();
#endif #endif
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
...@@ -27,6 +27,8 @@ ...@@ -27,6 +27,8 @@
#include <string.h> #include <string.h>
#include <signal.h> #include <signal.h>
#include <sys/wait.h>
#include <opengl/x11/glxtest.hxx> #include <opengl/x11/glxtest.hxx>
#ifdef __SUNPRO_CC #ifdef __SUNPRO_CC
...@@ -36,6 +38,8 @@ ...@@ -36,6 +38,8 @@
#include <X11/Xlib.h> #include <X11/Xlib.h>
#include <X11/Xutil.h> #include <X11/Xutil.h>
#include <sal/log.hxx>
// stuff from glx.h // stuff from glx.h
typedef struct __GLXcontextRec *GLXContext; typedef struct __GLXcontextRec *GLXContext;
typedef XID GLXPixmap; typedef XID GLXPixmap;
...@@ -275,3 +279,15 @@ bool fire_glxtest_process() ...@@ -275,3 +279,15 @@ bool fire_glxtest_process()
*glxtest_pid = pid; *glxtest_pid = pid;
return true; return true;
} }
void reap_glxtest_process() {
pid_t * pid = getGlxPid();
if (*pid != 0) {
// Use WNOHANG, as it is probably better to have a (rather harmless) zombie child process
// hanging around for the duration of the calling process, than to potentially block the
// calling process here:
pid_t e = waitpid(*pid, nullptr, WNOHANG);
SAL_INFO_IF(
e <= 0, "vcl.opengl", "waiting for glxtest process " << *pid << " failed with " << e);
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment