Only strip newline in OrderedStreamingForkController
The controller should pass through lines of input exactly as they were provided, only stripping the trailing newline that delimits items. The trim was making `door` and `door ` equivilant but for the use case in search the distinction is important. Additionally check that the line is actually empty, don't throw away inputs like '0' which are falsy. Change-Id: Ifac910543fdb46a27da021e831e3e18befefcfc5
This commit is contained in:
parent
e2e9117a51
commit
c94dea7029
1 changed files with 12 additions and 5 deletions
|
|
@ -134,9 +134,12 @@ class OrderedStreamingForkController extends ForkController {
|
||||||
*/
|
*/
|
||||||
protected function consumeNoFork() {
|
protected function consumeNoFork() {
|
||||||
while ( !feof( $this->input ) ) {
|
while ( !feof( $this->input ) ) {
|
||||||
$line = trim( fgets( $this->input ) );
|
$data = fgets( $this->input );
|
||||||
if ( $line ) {
|
if ( $data[ strlen( $data ) - 1 ] == "\n" ) {
|
||||||
$result = call_user_func( $this->workCallback, $line );
|
$data = substr( $data, 0, -1 );
|
||||||
|
}
|
||||||
|
if ( strlen( $data ) !== 0 ) {
|
||||||
|
$result = call_user_func( $this->workCallback, $data );
|
||||||
fwrite( $this->output, "$result\n" );
|
fwrite( $this->output, "$result\n" );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -160,8 +163,12 @@ class OrderedStreamingForkController extends ForkController {
|
||||||
$this->updateAvailableSockets( $sockets, $used, $sockets ? 0 : 5 );
|
$this->updateAvailableSockets( $sockets, $used, $sockets ? 0 : 5 );
|
||||||
} while ( !$sockets );
|
} while ( !$sockets );
|
||||||
}
|
}
|
||||||
$data = trim( $data );
|
// Strip the trailing \n. The last line of a file might not have a trailing
|
||||||
if ( !$data ) {
|
// \n though
|
||||||
|
if ( $data[ strlen( $data ) - 1 ] == "\n" ) {
|
||||||
|
$data = substr( $data, 0, -1 );
|
||||||
|
}
|
||||||
|
if ( strlen( $data ) === 0 ) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
$socket = array_pop( $sockets );
|
$socket = array_pop( $sockets );
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue