*/
protected function consumeNoFork() {
while ( !feof( $this->input ) ) {
- $line = trim( fgets( $this->input ) );
- if ( $line ) {
- $result = call_user_func( $this->workCallback, $line );
+ $data = fgets( $this->input );
+ if ( $data[ strlen( $data ) - 1 ] == "\n" ) {
+ $data = substr( $data, 0, -1 );
+ }
+ if ( strlen( $data ) !== 0 ) {
+ $result = call_user_func( $this->workCallback, $data );
fwrite( $this->output, "$result\n" );
}
}
$this->updateAvailableSockets( $sockets, $used, $sockets ? 0 : 5 );
} while ( !$sockets );
}
- $data = trim( $data );
- if ( !$data ) {
+ // Strip the trailing \n. The last line of a file might not have a trailing
+ // \n though
+ if ( $data[ strlen( $data ) - 1 ] == "\n" ) {
+ $data = substr( $data, 0, -1 );
+ }
+ if ( strlen( $data ) === 0 ) {
continue;
}
$socket = array_pop( $sockets );