Seb35 has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/347417 )

Change subject: Add a timeout in wfShellExec
......................................................................

Add a timeout in wfShellExec

In wfShellExec the function stream_select waits indefinitely until some
data comes; in some race cases it really hangs indefinitely the normal
execution of MediaWiki. One such race case is when more than 1024 files
are opened simultaneously and when PHP is compiled with FD_SETSIZE=1024;
it can be the case in some shared webservers or with PHPDBG during unit
tests.

This patch adds a timeout of 10 seconds (something like “very long” but
anyway bounded) and a condition to loop without reading the file
descriptors if no one is changed (which occurs when the timeout is
reached).

Bug: T72357
Change-Id: I506bfef7cd10ae137c33907fd056caa15000a51f
---
M includes/GlobalFunctions.php
1 file changed, 4 insertions(+), 1 deletion(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core 
refs/changes/17/347417/1

diff --git a/includes/GlobalFunctions.php b/includes/GlobalFunctions.php
index 3747c23..182d920 100644
--- a/includes/GlobalFunctions.php
+++ b/includes/GlobalFunctions.php
@@ -2429,7 +2429,7 @@
        $eintrMessage = "stream_select(): unable to select [$eintr]";
 
        $running = true;
-       $timeout = null;
+       $timeout = 10;
        $numReadyPipes = 0;
 
        while ( $running === true || $numReadyPipes !== 0 ) {
@@ -2459,6 +2459,9 @@
                                $logMsg = $error['message'];
                                break;
                        }
+               } elseif ( $numReadyPipes === 0 ) {
+                       // Timeout for now, continue until some data arrives
+                       continue;
                }
                foreach ( $readyPipes as $fd => $pipe ) {
                        $block = fread( $pipe, 65536 );

-- 
To view, visit https://gerrit.wikimedia.org/r/347417
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I506bfef7cd10ae137c33907fd056caa15000a51f
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Seb35 <se...@seb35.fr>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to