RE: [PHP-DEV] SLEEP and MAXEXECUTIONTIME and NAUGHTY modules

2001-02-28 Thread Sam Liddicott



> -Original Message-
> From: Andi Gutmans [mailto:[EMAIL PROTECTED]]
> Sent: Tuesday, February 27, 2001 08:03
> To: Sam Liddicott; [EMAIL PROTECTED]
> Subject: Re: [PHP-DEV] SLEEP and MAXEXECUTIONTIME and NAUGHTY modules
> 
> 
> At 12:11 PM 2/26/2001 +, 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
question:

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


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
systems.


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 
> >#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  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?

Sam

-- 
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]




Re: [PHP-DEV] SLEEP and MAXEXECUTIONTIME and NAUGHTY modules

2001-02-27 Thread Andi Gutmans

At 12:11 PM 2/26/2001 +, 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()?


>2) Could we not use:
>
>#include 
>#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?

Andi


>as well as being more accurate it would not break max-execution-time.
>
>And while we are at it define php_msleep for milliseconds?
>
>--
>PHP Development Mailing List 
>To unsubscribe, e-mail: [EMAIL PROTECTED]
>For additional commands, e-mail: [EMAIL PROTECTED]
>To contact the list administrators, e-mail: [EMAIL PROTECTED]


-- 
PHP Development Mailing List 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP-DEV] SLEEP and MAXEXECUTIONTIME and NAUGHTY modules

2001-02-26 Thread Sam Liddicott

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.

2) Could we not use:

#include 
#define sleep (n) \
 { struct timeval tv; \
   tv.tv_sec=n; \
   tv.tv_usec=0; \
   select(0,NULL,NULL,NULL,&tv); \
 }

as well as being more accurate it would not break max-execution-time.

And while we are at it define php_msleep for milliseconds?

-- 
PHP Development Mailing List 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]