> -----Original Message-----
> From: Andi Gutmans [mailto:[EMAIL PROTECTED]]
> Sent: Tuesday, February 27, 2001 08:03
> To: Sam Liddicott; [EMAIL PROTECTED]
> At 12:11 PM 2/26/2001 +0000, Sam Liddicott wrote:
> >I notice that usleep and sleep both clash on solaris with
> >Max-execution-time.
> >
> >1) I notice various modules using sleep:
> >db, hyperwave, mysql, oci8, satellite
> >which seems to break max execution time.
> Any idea why and where they are using sleep()?

Further investigation seems to reveal that use of alarm in OCI8 (oracle
supplied libs actually) on solaris combined with lwp_alarm and oracle
threading issue are breaking max execution time.  However to answer the

db: db.c in php_dbm_open() for an NFS locking loop:
if (lock) {

hyperwave: hg_comm.c in hg_read()/hg_write(), php_sleep used with
non-blocking socket to allow up to 5 seconds to try and read.  IMHO they
should either block or return what bytes are available and let the user deal
with it.  5 seconds is pretty arbitrary.

With mysql one use is a BSD threading broken select hack so I guess its no
issue for now.
The other mysql use is in my_write.c function my_write and is used to allow
a full file system to empty somewhat so the write can succeed.

oci8: oci8.c calls php_sleep(3) in oci_failover_callback()

satellite was a read herring.

standard: uniqid.c in PHPFUNCTION(uniqid) uses usleep(1) to wait for more
entropy, usleep also uses sigalarm and may break other alarms on some

It appears that all these uses of sleep could be replaced by the #define
sleep with the select function below

> >2) Could we not use:
> >
> >#include <unistd.h>
> >#define sleep(n) \
> >  { struct timeval tv; \
> >    tv.tv_sec=n; \
> >    tv.tv_usec=0; \
> >    select(0,NULL,NULL,NULL,&tv); \
> >  }
> Where did you see that?

I just made it up; left over from my perl days where
select(undef,undef,undef,$msecs); was traditionally used for small sleeps.

It compiles into PHP fine that way on solaris, but #include <unistd.h> is
needed early because it (on Solaris) declares sleep and sleep being #defined
first breaks the declaration.

I'm not entirely happy with it, and other uses of ALARM will break max
execution time anyway...
Maybe the above should be PHP_SLEEP which I note some modules use, then we
can persuade developers to use PHP_SLEEP instead.

Not ot mention, I put it into main/php_config.h (after running configure)
but I'm not sure if this is included by all units which use sleep.  Hmmm...

What do you think?


PHP Development Mailing List <http://www.php.net/>
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to