php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #17934 sleep() no longer supported
Submitted: 2002-06-23 12:51 UTC Modified: 2002-06-24 14:21 UTC
From: matt at haught dot com Assigned:
Status: Not a bug Package: Apache2 related
PHP Version: 4.2.1 OS: FreeBSD 4.4-RELEASE
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: matt at haught dot com
New email:
PHP Version: OS:

 

 [2002-06-23 12:51 UTC] matt at haught dot com
I have a few scripts that use sleep() to provide a delay when incorrect passwords are given.  When using php snap php4-200206230600 + apache-2.0.39 + FreeBSD 4.4, i receive this error when trying to use "sleep(3);" :

Fatal error: Call to undefined function: sleep() in /home/bob/include/auth.inc.php on line 38



Please note that this function does work on Win32/apache2.0.35/php-4.2.0.  I will continue to try new snaps on the BSD box as soon as they are out.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2002-06-23 13:01 UTC] rasmus@php.net
That doesn't make any sense.  sleep() is not conditional in any way.  Could you show us line 38 of that file?
 [2002-06-23 13:17 UTC] matt at haught dot com
Here are lines 36 - 41
} else {
	//password or login did not match - try again
	sleep(3);
	header("Location:login.php?error=1");
	exit();
} //if

I have been compiling snaps daily, but I am not sure how long it has been doing this, as I had my caps lock on today and got the error when i tried to log into my site.

I just updated to snap php4-200206230900, and I still get the error.  What am i doing wrong?  Does sleep require something in apache2 that is causing the problems?  What else should I check, does anyone else get this?

I am currently using: 
if (function_exists('sleep')) {
	sleep(3);
}
to get around the error. But I really would like to use sleep().

--Matt
 [2002-06-23 13:38 UTC] rasmus@php.net
Well, it hasn't been removed from PHP in any way.  I have no idea why it isn't working for you.  However, you need to realize that Apache 2, especially on FreeBSD, is nowhere near production quality.  Apache2+PHP+FreeBSD is about as half-baked as you can get.
 [2002-06-23 13:57 UTC] matt at haught dot com
I know FreeBSD+apache2+php4 is very half baked, but it has been working somewhat well using the prefork mpm (apache.org after all is using the same thing without the php).  I switched to using usleep(3000000); and that works for some reason. (i think that equals 3 seconds).  I guess it is an apache2 problem.  I know apache2 is not high on your list of fixes, I was just trying to help.

I noticed that 

checking for usleep... (cached) yes

was in my configure output, should their also be a entry for sleep?  I am not a programmer so I have no idea.
 [2002-06-24 05:12 UTC] wez@php.net
You haven't got a disable_functions= line in your php.ini
or apache config, have you?
 [2002-06-24 13:37 UTC] matt at haught dot com
I don't have any disable_functions in either php.ini or apache's config.  I just updated my development machine which is running WinXP+apache2.0.39 and the latest snap, and sleep() works.  Could it be something with FreeBSD or apache2 on FreeBSD?  Does the sleep function require something from the OS or apache2 in order to work?  I have FreeBSD 4.6 on another machine that I am going compile everything to see if it exists there, i will get back to you.  Hopefully its not completely unique to my server :)

--Matt
 [2002-06-24 13:45 UTC] rasmus@php.net
Since we don't have any sort of configure checks for the sleep() function, I really don't see how this can happen.  However, it might be something related to running PHP in ZTS (threaded) mode.  Unless you have specifically built Apache2 on FreeBSD with a threaded MPM, then you really don't need the threaded version of PHP.  If you grab the latest CVS version of PHP and try again, it will build non-threaded against Apache2-prefork (which is the default mpm on fbsd) and perhaps this would fix this.  

Do a 'man sleep' as well.  Perhaps sleep() is not threadsafe on fbsd?  Sounds flaky though.  I don't see why sleep() wouldn't be threadsafe.
 [2002-06-24 14:18 UTC] matt at haught dot com
I just got done compiling apache2.0.39 and the latest 
snap on FreeBSD 4.6 and sleep works there.  They both have 
the exact same config except for the version of Fbsd.  It 
looks like a problem with FreeBSD 4.4 and/or the combo 
with apache2, or my system alone somehow.  I am using 
prefork, b/c i know the threaded apache absolutly does not 
work on this version of fbsd.  This looks like its not a 
php problem.  Thanks again for all your help.   (usleep 
does work on both, so if anyone else is having the same 
problem use that instead) 
 
-Matt
 [2002-06-24 14:21 UTC] sniper@php.net
bogus then..

 
PHP Copyright © 2001-2022 The PHP Group
All rights reserved.
Last updated: Mon Nov 28 23:03:43 2022 UTC