HHVM does not flush automatically until the output is done, unless
flush() is called. We create an output buffer so that PHP is aware
of the amount of data in the output buffer; we set ob_implicit_flush
so that, when output buffer is full and being flushed, it flushes
HHVM's buffer as well, emptying the OOM culprit.
Bug: T172851
Change-Id: I34dd1034590779ab51f197762177ad03291e3581
$path = $this->resolveToStoragePath( $virtualUrl );
$params = [ 'src' => $path, 'headers' => $headers, 'options' => $optHeaders ];
+ // T172851: HHVM does not flush the output properly, causing OOM
+ ob_start( NULL, 1048576 );
+ ob_implicit_flush( true );
+
$status = $this->newGood();
$status->merge( $this->backend->streamFile( $params ) );
+ ob_end_flush();
+
return $status;
}