Stop calling FileRepo->streamFile()
[lhc/web/wiklou.git] / includes / OrderedStreamingForkController.php
index ff29cb5..5424b13 100644 (file)
@@ -134,11 +134,17 @@ class OrderedStreamingForkController extends ForkController {
         */
        protected function consumeNoFork() {
                while ( !feof( $this->input ) ) {
-                       $line = trim( fgets( $this->input ) );
-                       if ( $line ) {
-                               $result = call_user_func( $this->workCallback, $line );
-                               fwrite( $this->output, "$result\n" );
+                       $data = fgets( $this->input );
+                       if ( substr( $data, -1 ) === "\n" ) {
+                               // Strip any final new line used to delimit lines of input.
+                               // The last line of input might not have it, though.
+                               $data = substr( $data, 0, -1 );
                        }
+                       if ( $data === '' ) {
+                               continue;
+                       }
+                       $result = call_user_func( $this->workCallback, $data );
+                       fwrite( $this->output, "$result\n" );
                }
        }
 
@@ -160,8 +166,12 @@ class OrderedStreamingForkController extends ForkController {
                                        $this->updateAvailableSockets( $sockets, $used, $sockets ? 0 : 5 );
                                } while ( !$sockets );
                        }
-                       $data = trim( $data );
-                       if ( !$data ) {
+                       if ( substr( $data, - 1 ) === "\n" ) {
+                               // Strip any final new line used to delimit lines of input.
+                               // The last line of input might not have it, though.
+                               $data = substr( $data, 0, -1 );
+                       }
+                       if ( $data === '' ) {
                                continue;
                        }
                        $socket = array_pop( $sockets );