Skip to content

Commit

Permalink
Fix wrong time unit in Service->delay()
Browse files Browse the repository at this point in the history
The delay() method misinterpreted its parameter as number in second while the value passed in are usually in millisecond.

This bug contributes to TCP `CLOSE_WAIT` issues on the server side when request is corrupted or exception occurs.
  • Loading branch information
zhangchn authored Mar 22, 2018
1 parent b6d266e commit be30164
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/Hprose/Service.php
Original file line number Diff line number Diff line change
Expand Up @@ -471,9 +471,9 @@ protected function doFunctionList() {
$stream->close();
return $data;
}
protected function delay($interval, $data) {
$seconds = floor($interval);
$nanoseconds = ($interval - $seconds) * 1000000000;
protected function delay($milliseconds, $data) {
$seconds = floor($milliseconds / 1000);
$nanoseconds = ($milliseconds % 1000) * 1000000;
time_nanosleep($seconds, $nanoseconds);
return Future\value($data);
}
Expand Down

0 comments on commit be30164

Please sign in to comment.