php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #77603 Unexpected behavior with reloading php-fpm and sleep method
Submitted: 2019-02-11 11:53 UTC Modified: -
Votes:1
Avg. Score:3.0 ± 0.0
Reproduced:0 of 0 (0.0%)
From: aliborhani1 at gmail dot com Assigned:
Status: Open Package: FPM related
PHP Version: 7.3.2 OS: Ubuntu 18.04.2 LTS
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2019-02-11 11:53 UTC] aliborhani1 at gmail dot com
Description:
------------
When I use sleep() method in my script and set `process_control_timeout` to `20s` in php-fpm.conf, I see unexpected behavior when I reload the php-fpm. It seems it doesn't respect the sleep's argument (e.g. 10 seconds) and wakes up the script too early. 

However, when I use `exec('sleep 10')` instead, it works correctly:


```
[02-11-2019 11:39:15] before sleep
[02-11-2019 11:39:25] after sleep
[02-11-2019 11:39:25] after echo
```


PHP Version: PHP 7.3.2-3+ubuntu18.04.1+deb.sury.org+1 (cli) (built: Feb  8 2019 15:43:57) ( NTS )
Webserver: Nginx - using unix socket

Test script:
---------------
<?php

slog("before sleep");

// this works:
// exec('sleep 10');

// but, this doesn't work:
sleep(10);

slog("after sleep");

echo "Done!" . PHP_EOL;
slog("after echo");


function slog(string $text) {
    $text = '[' . strftime("%m-%d-%Y %H:%M:%S") . '] ' . $text . PHP_EOL;
    file_put_contents(__DIR__ . '/app.log', $text, FILE_APPEND);
}

Expected result:
----------------
[02-11-2019 11:38:43] before sleep
[02-11-2019 11:38:53] after sleep
[02-11-2019 11:38:53] after echo

Actual result:
--------------
[02-11-2019 11:38:43] before sleep
[02-11-2019 11:38:46] after sleep
[02-11-2019 11:38:46] after echo

Patches

Add a Patch

Pull Requests

Add a Pull Request

 
PHP Copyright © 2001-2019 The PHP Group
All rights reserved.
Last updated: Mon Oct 21 05:01:27 2019 UTC