bug 1400839 use -1 instead of 0 to indicate absent glxtest_pipe fd r=karlt
authorsebastian@ifyouwantblood.de
Tue, 19 Sep 2017 11:47:12 +1200
changeset 381565 fd4481cbbd29
parent 381564 11b46d2109c4
child 381566 b2e85eb4879d
push id32532
push userarchaeopteryx@coole-files.de
push dateTue, 19 Sep 2017 09:08:57 +0000
treeherdermozilla-central@7c12af6fd620 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskarlt
bugs1400839
milestone57.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
bug 1400839 use -1 instead of 0 to indicate absent glxtest_pipe fd r=karlt Englightenment closes fd 0 on child processes and so pipe() can return a zero fd. MozReview-Commit-ID: 5d9xQXgwgfv
widget/GfxInfoX11.cpp
--- a/widget/GfxInfoX11.cpp
+++ b/widget/GfxInfoX11.cpp
@@ -23,17 +23,17 @@
 namespace mozilla {
 namespace widget {
 
 #ifdef DEBUG
 NS_IMPL_ISUPPORTS_INHERITED(GfxInfo, GfxInfoBase, nsIGfxInfoDebug)
 #endif
 
 // these global variables will be set when firing the glxtest process
-int glxtest_pipe = 0;
+int glxtest_pipe = -1;
 pid_t glxtest_pid = 0;
 
 nsresult
 GfxInfo::Init()
 {
     mGLMajorVersion = 0;
     mMajorVersion = 0;
     mMinorVersion = 0;
@@ -50,27 +50,27 @@ GfxInfo::Init()
 }
 
 void
 GfxInfo::GetData()
 {
     // to understand this function, see bug 639842. We retrieve the OpenGL driver information in a
     // separate process to protect against bad drivers.
 
-    // if glxtest_pipe == 0, that means that we already read the information
-    if (!glxtest_pipe)
+    // if glxtest_pipe == -1, that means that we already read the information
+    if (glxtest_pipe == -1)
         return;
 
     enum { buf_size = 1024 };
     char buf[buf_size];
     ssize_t bytesread = read(glxtest_pipe,
                              &buf,
                              buf_size-1); // -1 because we'll append a zero
     close(glxtest_pipe);
-    glxtest_pipe = 0;
+    glxtest_pipe = -1;
 
     // bytesread < 0 would mean that the above read() call failed.
     // This should never happen. If it did, the outcome would be to blacklist anyway.
     if (bytesread < 0)
         bytesread = 0;
 
     // let buf be a zero-terminated string
     buf[bytesread] = 0;