Re: [PHP-DEV] request data filter

2003-01-15 Thread George Schlossnagle
You consider running the apache_hooks code?  This should be simple 
there.


--
PHP Development Mailing List 
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DEV] request data filter

2003-01-15 Thread George Schlossnagle
You could have your custom C extension be called as one of the hooks.

On Wednesday, January 15, 2003, at 09:42  PM, Rasmus Lerdorf wrote:


On Wed, 15 Jan 2003, George Schlossnagle wrote:


You consider running the apache_hooks code?  This should be simple
there.


You mean do the filtering straight from a PHP script that gets called 
from
a hook?  That's a lot of looping through a bunch of arrays.  This has 
to
happen on every request on the busiest site in the world; it needs to 
be
written in C.

You could have your custom C extension be called as one of the hooks.

Shouldn't be any slower than what you proposed.



-Rasmus


--
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, visit: http://www.php.net/unsub.php




--
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP-DEV] Distributing Extensions

2003-01-22 Thread George Schlossnagle

On Thursday, January 23, 2003, at 12:17  AM, Brian Moon wrote:

 Is PECL ready for this stuff?


Yes.


--
PHP Development Mailing List 
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP-DEV] Register Shutdown Function for Apache

2003-01-23 Thread George Schlossnagle
What is the current state of the patches?  I know there where a couple 
implementations discussed and discarded.  It would seem to me to be 
impossible to endorse commiting them without seeing their current 
state.  If the current patch you're running against 4.3.0 has been 
posted elsewhere on the list, my apologies and can you send a link to 
the archives for it?

On Thursday, January 23, 2003, at 11:38  AM, Joseph Tate wrote:

I can have the patches ready to go in a very short amount of time.  
I'll
work on and post them if I can be reasonably sure they'll be committed.


--
PHP Development Mailing List 
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP-DEV] Reducing the number of system calls for includes

2003-01-24 Thread George Schlossnagle
Eliminating realpath for fully qualified paths make sense to me.

But...  don't you Y! guys use php-a?  Shouldn't this hide that overhead 
completely from you by completely eliminating all the stats on a 
require/include after the initial compilation?  Or is this just a 
'greater good' optimization?

George


--
PHP Development Mailing List 
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DEV] Reducing the number of system calls for includes

2003-01-24 Thread George Schlossnagle
On Friday, January 24, 2003, at 10:19  PM, Rasmus Lerdorf wrote:


Eliminating realpath for fully qualified paths make sense to me.

But...  don't you Y! guys use php-a?  Shouldn't this hide that 
overhead
completely from you by completely eliminating all the stats on a
require/include after the initial compilation?  Or is this just a

It doesn't eliminate it at all, no.  These checks are still done even 
on
accelerated includes in both zend cache and ioncube.

Weird.  That was totally contrary to the way I remember it working.  In 
trying to figure out why I remembered incorrectly, I realized the 
reason why you (in general) want to resolve the path to a canonical 
path is that you can seriously break include_once and require_once if 
you dont.  Otherwise require_once wont correctly work if you do


  require_once("/home/george/foo.php");
  require_once("/home/george/../george/foo.php");
?>

(of course you can put together a less contrived example).


--
PHP Development Mailing List 
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DEV] Reducing the number of system calls for includes

2003-01-25 Thread George Schlossnagle
I like this solution.

On Saturday, January 25, 2003, at 09:08  AM, Andi Gutmans wrote:


Hi,

I think the best solution to this problem, without breaking 
functionality, is to use a cache for realpath() in virtual_file_ex().


--
PHP Development Mailing List 
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP-DEV] Reducing the number of system calls for includes

2003-01-25 Thread George Schlossnagle
Perhaps make it configurable because on Linux there already is a dcache
right in the kernel which is likely to be faster than anything we can 
do.

On linux you still have to make all those stat calls (they just return 
fast).  A hashlookup inside TSRM will almost certainly return much 
faster.


As far as I know, Linux is the only OS with such a kernel-level cache.


Isn't solaris' dnlc similar in function to linux's dcache?


--
PHP Development Mailing List 
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP-DEV] Re: Mandatory File Locking in PHP?

2003-01-29 Thread George Schlossnagle
Aside from this being on the wrong list (this should go to 
php-general), it's worth noting that mandatory locking support is 
pretty inconsistently implemented across most OSs.

George

On Wednesday, January 29, 2003, at 10:59  AM, J Smith wrote:


Try the direct I/O extension, specifically dio_fcntl(). Just make sure 
the
filesystem you're using the locks on was mounted with "-o mand", and 
the
locks will be mandatory by default.

J


Ananth Kesari wrote:

Hi,

From the PHP manual I find that the flock() function does a advisory
file locking. Is there a way to do mandatory file locking where we do
strict locking? That is once a file is locked, no other process or
thread is allowed to edit the file untill the lock owner is done with
his job and he has removed the lock.

Thanks,
Ananth.



--
PHP Development Mailing List 
To unsubscribe, visit: http://www.php.net/unsub.php




--
PHP Development Mailing List 
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP-DEV] Re: Mandatory File Locking in PHP?

2003-01-29 Thread George Schlossnagle

On Wednesday, January 29, 2003, at 06:26  PM, Marcus Börger wrote:


At 18:07 29.01.2003, George Schlossnagle wrote:

Aside from this being on the wrong list (this should go to 
php-general), it's worth noting that mandatory locking support is 
pretty inconsistently implemented across most OSs.


Why wrong list?


My fault, I interpreted it to be a 'how do I use mandatory locks (as a 
user)'

Inside dba i use flock compatibility routines. If you can show us how 
to do that
on Netware or if you can use those mechanisms then both (streams and 
netware
port) would benefit.

The real question is why you need mandatory locks and not advisory 
locks.  If everyone is playing on the same team, advisory locks should 
provide all the semantics you need (and are very portable).  Mandatory 
locks (on linux at least) require not only special mount options, but 
special perms to the file (g-x, g+s, I believe).  That seems like a lot 
to require inside an extension.



--
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DEV] Re: Mandatory File Locking in PHP?

2003-01-29 Thread George Schlossnagle

On Wednesday, January 29, 2003, at 07:11  PM, Marcus Börger wrote:




The real question is why you need mandatory locks and not advisory 
locks.  If everyone is playing on the same team, advisory locks 
should provide all the semantics you need (and are very portable).  
Mandatory locks (on linux at least) require not only special mount 
options, but special perms to the file (g-x, g+s, I believe).  That 
seems like a lot to require inside an extension.

The dba solution so far is based on flock() and where not appropriate 
use fctnl().
I tried to have the lock stuff working on as many systems as possible.

Right.  Both of these are pretty portable, one being present on all 
BSD-style systems and the other on POSIX systems.  They are also 
advisory locks.  Mandatory locks actually prevent read and write calls 
from _anyone_ else succeeding on that file.  On linux, mandatory locks 
are set with fcntl, but it's not part of the standard POSIX standard.


--
PHP Development Mailing List 
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DEV] Re: Mandatory File Locking in PHP?

2003-01-30 Thread George Schlossnagle

On Thursday, January 30, 2003, at 04:28  AM, Ananth Kesari wrote:


So, as of now, do we restrict PHP script to use only advisory file 
locking?

Mandatory locking is an OS thing, not a PHP userspace thing.  Given 
appropriate mount options on your fs (certainly out of the scope of 
php's responsibility), and appropriate permissions on the file (doable 
from within php of course, but seems odd to have to internally check 
and chmod a file as part of a locking procedure), then fcntl locks will 
be mandatory.

Assuming that your filesystem is mounted -o mand, you can just do this:

function mandatoryLock($file) {

	// go through the arcane dance of setting g+s, g-x
	$mode = (stat($file)[2)];
	$mode = $mode ^ 0010;
	$mode = $mode | 02000;
 chmod($file, $mode);

	// lock it
 $fp = open($file, "a+");
 flock($fp,  LOCK_EX);
}


The point I'm trying to make, is that you can already set up your 
system so that you can do mandatory locks from within php (on systems 
supporting it), but it is close to impossible to have php do all the 
setup work for you (remounting a file system -o mand should be out of 
the scope of php, imho).

George


--
PHP Development Mailing List 
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DEV] OO in PHP5 (was "zend_API.c" on php-dev)

2003-02-03 Thread George Schlossnagle

On Monday, February 3, 2003, at 03:20  PM, Harald Radi wrote:


Hrmfpsd,

while commiting a new functions the parameter parsing API i appearently
brought up a discussion about the meaning of life and stuff :) As 
asked by
Andi i'm bringing the discussion to php5-dev with a short summary:

andrei's point:
extensions should stick to either functional or oo API
PEAR wrappers can be provided

my point:
extensions should expose both APIs (if desired)
can be done by aliasing functions to class methods -> no duplicate c 
code
when called as function -> print warning
when called as method -> throw exception

What do you guys think of this ?

I like your method.  I've implemented it for a coupe extensions (except 
for the exception vs. error thing), and I found it to be quite 
manageable and very little work.


regards,
Harald Radi
--
nme - we can heal you
http://www.nme.at

Ortner Radi Schwenk GnbR
Tumpenweg 528
5084 Grossgmain, Salzburg
Austria


-Original Message-
From: Andi Gutmans [mailto:[EMAIL PROTECTED]]
Sent: Monday, February 03, 2003 9:10 PM
To: Harald Radi; 'Andrei Zmievski'
Cc: [EMAIL PROTECTED]
Subject: Re: [PHP-DEV] RE: zend_API.c


Hey,

I think the discussion you guys are having is much broader than just
mysqli. We should probably come up with a general approach
which we will
use consistently for PHP 5.
I suggest we move this discussion to the PHP 5 dev list and
try and come up
with a good solution. Obviously we will keep the functional
support for all
extensions like PHP 4. The only question is, if and how we
support an OO
paradigm.

Andi





--
PHP Development Mailing List 
To unsubscribe, visit: http://www.php.net/unsub.php




--
PHP Development Mailing List 
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP-DEV] Mono & PHP

2003-02-05 Thread George Schlossnagle

On Wednesday, February 5, 2003, at 05:22  PM, Stig S. Bakken wrote:


On Mon, 3 Feb 2003, Sebastian Bergmann wrote:


Sterling Hughes wrote:

I'll be adding it into PECL in a little bit


  Why PECL and not add it to ext/rpc?


ext/rpc should be able to load "rpc backend" modules, or PECL is the 
only
sensible place to put it (especially when it's experimental!).  We 
really
don't want to mix java, mono, xmlrpc, soap and whatnot into a single
package.

Nor (as cool as it may be), is there a reason it should be in the 
'core' (extension-wise) of php.


--
PHP Development Mailing List 
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DEV] include() and sessions

2003-02-11 Thread George Schlossnagle
Interesting, I get the same hang when I do this on OSX with head

php 'foo.php?a=b'

Foo is any php script (including an empty file).

This returns no such file foo.php?a=b on linux.

Will open a bug.

George

On Tuesday, February 11, 2003, at 05:31  PM, Lindsey Simon wrote:


Hey Chris, sorry - I only included it on this list because of the 
server
timeout thing. When I pass the session id and name my server hangs on
the include. I thought it might be pertinent.

Also, as a guess to your problem, when you include a resource by URL, 
you are
going to receive the same output that a browser would (when you view 
source),
so any PHP code in that resource is going to be executed prior to 
receipt. If
this is a local file, you should use the filesystem path instead. For 
example:


include '/home/lindsey/public_html/foo.php';

instead of:

include 'http://www.example.org/~lindsey/foo.php';


This is correct, I want the code to be executed. Specifically, I want 
to
pass GET variables along with the include that are not the same as the
current state of the GET variables on the page I'm calling include 
from.

If you must use a URL and you want to retain session, you will have 
to pass
your session identifier on the URL.

(see above)


Chris

--- Lindsey Simon <[EMAIL PROTECTED]> wrote:

I have a situation involving my session and an include().

I'm trying to include() a page using the full path. My session is
registered and I can verify all is well with it. I want to retain the
session from within the page I'm including.

So:

I'm pasting my code here (please ignore the variables except the 
session
stuff at the end.

$this_URL = $URL . "index.php?modu=display_shots&show_ident=" .
$_REQUEST['select_ident'] . "&select_ident=" . 
$_REQUEST['select_ident']
.. "&noheader=1&nofooter=1&no_print_link=1&add_record=1&" .
session_name() . "=" . session_id();
include($this_URL);

my webserver just hangs and I have to restart it in order to get any
more pages from anywhere on the server.

I've tested this in 4.2.3 and 4.3.

Is my syntax correct in terms of what I should append to the
URL when include()ing it? I'm basing it on what I read about passing 
SID
(which I can't use since it's returning empty on the page where I 
have
the include() line)

Thanks for your help,
-l

--
PHP Development Mailing List 
To unsubscribe, visit: http://www.php.net/unsub.php




--
PHP Development Mailing List 
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP-DEV] Of string constants, bytecode, and concatenation

2003-02-26 Thread George Schlossnagle
It's the job of an optimizer, not of a compiler. And because PHP 
doesn't
have an internal optimizer, this is not optimized out. You can either
check the ZendOptimiser (I can't show you the opcodes that that
generates) or PEAR::Optimizer, which is in Pecl (which might not do 
this
optimization yet btw).
It does.

--
PHP Development Mailing List 
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP-DEV] Re: [PHP] Threading

2003-02-27 Thread George Schlossnagle
On Thursday, February 27, 2003, at 01:50  PM, Braulio JosX Solano Rojas 
wrote:

Hi!

"Dave Viner" <[EMAIL PROTECTED]> escribiÛ en el mensaje
news:[EMAIL PROTECTED]
would semaphores provide the "mutual exclusion zone" you need?
I do not know yet, I should studie it, but it is likely so.

Are there semaphores in PHP?
Yes.  I'd recommend a reading of the fine manual.

Of course if you're actually writing an extension it doesn't matter 
much if the semaphores are implemented in PHP or not, since you'll 
probably just want to use the sysv ipc support of the os yourself, 
without taking it through php userland functions.

george

--
PHP Development Mailing List 
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP-DEV] Weak references in PHP

2003-02-28 Thread George Schlossnagle
Can anybody tell me if such features are available in PHP (I failed to 
find
them myself).
Look at __destruct method for classes in ZE2.  They wopn't tell you the 
reference count, but the do get called when the ref count goes to 0.

--
PHP Development Mailing List 
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP-DEV] #php.bugs invite only?

2003-02-28 Thread George Schlossnagle
#php.bugs seems to be invite only now.  How do I go about getting 
myself invited?

--
PHP Development Mailing List 
To unsubscribe, visit: http://www.php.net/unsub.php


Re: Re[2]: [PHP-DEV] Weak references in PHP

2003-02-28 Thread George Schlossnagle
Using __destruct method (thanks to George) it may be possible to 
implement
what I need, but only if object cache is implemented in C (and so is
not visible for PHP garbage collector). So no pure PHP solution exits.
Unfortunately I didn't fins any reference to __destruct method in PHP
manual and do not understand how it works. If I just declare
__destruct method in class, it is not invoked when object is
destructed.
It's in ZE2  have a look at Zend/ZEND_CHANGES in the source tree for 
details (you'll need to be running php5/HEAD).  And it's a userland 
method, so the cache can be implemented in PHP.

--
PHP Development Mailing List 
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP-DEV] Tie'ing variables

2003-03-01 Thread George Schlossnagle
Having this sort of functionaility in general would be great.  I know 
you can affect this with objects via overload, but it is useful for 
scalars and arrays and streams as well.  It is pretty 'magical' though.

George

On Saturday, March 1, 2003, at 11:26  AM, Sterling Hughes wrote:

I was wondering if it might be possible to "tie" these arrays to a
function (if you don't understand that, look at Perl for a definition).
One could populate them as an overloaded object, and then array 
accesses
would work - I guess.  But I would prefer a cleaner mechanism.


--
PHP Development Mailing List 
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP-DEV] session extension question

2003-03-01 Thread George Schlossnagle
Any feelings on a patch to the session extension so that if 
session_set_save_handler is passed a class or namespace as it's sole 
argument, it auto-registers class::open, class::close, class::read, 
class::write, class::destory and class::gc?

George

--
PHP Development Mailing List 
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP-DEV] Re: #22527 [Opn->Bgs]: Modulus returned negative value

2003-03-04 Thread George Schlossnagle
Interesting.

I don't know what the ISO standard say, but mathematically a a % b will 
always return you an integer 0 <= a%b < b (since there are no negative 
numbers in canonical representation of Z/bZ).  I guess perl/python/tcl 
ddecided to adhere to the mathematical definition.

On Tuesday, March 4, 2003, at 02:37  AM, Rasmus Lerdorf wrote:

This is actually an interesting question.  Should we be truncating 
towards
zero?  I'd say yes, but then I tested Perl, Python and Tcl, and they 
all
say that -27 % 7 is 1 which means they truncate towards negative 
infinity.


--
PHP Development Mailing List 
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP-DEV] Re: #22527 [Opn->Bgs]: Modulus returned negative value

2003-03-04 Thread George Schlossnagle
On Tuesday, March 4, 2003, at 10:33  AM, Sascha Schumann wrote:

On Tue, 4 Mar 2003, George Schlossnagle wrote:

Interesting.

I don't know what the ISO standard say, but mathematically a a % b 
will
always return you an integer 0 <= a%b < b (since there are no negative
numbers in canonical representation of Z/bZ).  I guess perl/python/tcl
ddecided to adhere to the mathematical definition.
ISO C truncates towards zero.  It specifically says in 6.5.5
Multiplicative Operators:
If the quotient a/b is representable, the expression (a/b)*b
+ a%b shall equal a.
So -27 % 7 yields -6.
Yeah, I read that in the bug report and confirmed that as the intended 
behavior in C.  What I meant was 'regardless of what the ISO standard 
says, thats not a standard mathematical definition.'

--
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP-DEV] Question about zend_compile

2003-03-05 Thread George Schlossnagle
Look at apc.  It tracks per-file function and class tables.

http://apc.communityconnect.com/  (v2.0)
pear/PECL/apc (v1.x)
Both versions do the thing you wish for.

--
PHP Development Mailing List 
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP-DEV] Re: [Zend Engine 2] FYI: PHP/threads

2003-03-05 Thread George Schlossnagle
Both of these examples could be realized using fork() or
socket_select(), though the first is not portable and the latter
produces unnecessary overhead.


Just to nit-pick: non-blocking io is much more efficient than threads,

--
PHP Development Mailing List 
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP-DEV] Doing something with an each opcode as zend_execute() handles it

2003-03-05 Thread George Schlossnagle
Essentially, I want to be able to produce a sort of serialized
representation of the opcodes, but as they are executed, not all in 
one big
chunk after they are compiled.

This isn't for any actually useful production code, just some
debugging/messing around/exploring engine internals.
There's no good way to do this as a zend_extension in ZE1 (that I know 
of).  You need to patch the engine (which is trivial).

--
PHP Development Mailing List 
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP-DEV] Help a beginner out please!!

2003-03-06 Thread George Schlossnagle
Wrong list.  You're looking for [EMAIL PROTECTED]  This is a 
list for the development of the language itself, not with it.

On Friday, March 7, 2003, at 12:44  AM, Ted Conn wrote:

Hi well maybe this isnt the right place to put a beginners post but I 
will
find out soon if its not I guess!


--
PHP Development Mailing List 
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP-DEV] trans-sid warning?

2002-08-19 Thread George Schlossnagle


On Monday, August 19, 2002, at 07:56 PM, Rasmus Lerdorf wrote:
>>
>> To conclude: Don't trade useful features for pseudo security.
>> Removing this feature just increases the feeling of having a
>> 'secure' site and decreases the desire to protect oneself by
>> activating session.use_only_cookies.
>
> I do agree with that, I just wasn't convinced that it was a useful
> feature.

To play devil's advocate, pure cookie based authentication is not a 
panacea.  If you allow users to put things like javascript on your site, 
or if you have users who exploit ie bugs like the about: cookie domain 
bug from last year, cookies can be stolen and session hijacked.  pure 
cookie auth is definitely a good thing, but does not provide safety in a 
number of 'real world' applications.

George


-- 
PHP Development Mailing List 
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP-DEV] trans-sid warning?

2002-08-19 Thread George Schlossnagle


On Monday, August 19, 2002, at 10:24 PM, Xavier Spriet wrote:

> (I might have sent this one twice again...)
> --
> why not simply allow a maximum amount of time a session can exist 
> (let's say, 25 minutes).
> This could be customised or even disabled by the administrator so it 
> won't be a flea to regular users, and even though it won't be 
> bulletproof, it will make things considerably more complicated for the 
> attacker.
> Sending a link and hoping it will be clicked in the next 25 minutes is 
> just trying your luck.

Again, this is a good step, but is not at all effective against an 
attacker motivated to compromise your site.


>
> Also a good web developer aware of this will most certainly put a 
> little informing text such as:
> You are currently loged in as:   you loged in with the following 
> IPaddr/Uagent:   blablah.

The problem is, while this means something to the developer, it means 
nothing to the average end-user, especially since most large ISP users 
will have ip's that fluctuate form request-to-request.


>
> Xavier.
>
>   -Original Message-
>   From: Sascha Schumann [mailto:[EMAIL PROTECTED]]
>   Sent: Mon 19/08/2002 8:50 PM
>   To: George Schlossnagle
>   Cc: Rasmus Lerdorf; Yasuo Ohgaki; [EMAIL PROTECTED]
>   Subject: Re: [PHP-DEV] trans-sid warning?
>   
>   
>
>   > To play devil's advocate, pure cookie based authentication is not a
>   > panacea.  If you allow users to put things like javascript on 
> your site,
>   > or if you have users who exploit ie bugs like the about: cookie 
> domain
>   > bug from last year, cookies can be stolen and session hijacked.  
> pure
>   > cookie auth is definitely a good thing, but does not provide 
> safety in a
>   > number of 'real world' applications.
>   
>   Yes, I pointed that out in an earlier discussion about this
>   topic.  A online-banking site could for example check the
>   browser for certain types of common vulnerabilities and post
>   a nice "please upgrade" dialogue.
>   
>   This would exclude IE by default though, because there are
>   quite a load of unfixed, publically known security bugs.
>   
>   http://www.jscript.dk/unpatched/ listed them, but the page
>   seems to be down now.  Google still finds
>   
>   http://www.jscript.dk/unpatched/MS02-023update.html
>   
>   "Yesterday I hosted a list of 14 publickly known unpatched
>   vulnerabilities, today I host a list of 12 such. It can still
>   be found at http://jscript.dk/unpatched/
>   
>   - Sascha
>   
>   
>   --
>   PHP Development Mailing List <http://www.php.net/>
>   To unsubscribe, visit: http://www.php.net/unsub.php
>   
>   
>
>
// George Schlossnagle
// Principal Consultant
// OmniTI, Inc  http://www.omniti.com
// (c) 240.460.5234   (e) [EMAIL PROTECTED]
// 1024D/1100A5A0  1370 F70A 9365 96C9 2F5E 56C2 B2B9 262F 1100 A5A0


-- 
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP-DEV] trans-sid warning?

2002-08-20 Thread George Schlossnagle

Dan Hardiker wrote:

>>>Well, more worrisome would be if a bad guy tricks you into clicking on
>>>a link or simply sends you an image in an email that makes a request
>>>to my server with a valid-looking session id.  Then if you go to this
>>>site (that
>>>
>>I've debunked that scenario already a few times.  The net
>>result is that this class of attacks is impossible to
>>prevent.
>>
>>The assumption in your scenario and the following is this:
>>
>>The attacker has access to a script X which calls
>>session_start().
>>
>>My scenario:
>>
>>1.) Attacker A accesses X and stores the SID which PHP assigns to
>>him.
>>
>>2.) A crafts a link containing SID and sends it to victim V.
>>
>>3.) A keeps SID alive by repeatedly accessing X using SID.
>>
>>4.) V opens link and authenticates.
>>
>>5.) A's script notices (4).  A can overtake V's session.
>>
>
>Ive extended the session handling so that upon session start, it takes a
>snapshot of the browser string (and maybe a couple of other
>javascript-retrieved variables about the user's os, eg: the resolution)
>and build up as much of a picture of the client as possible.
>
>Then store this with the session id, and each time its loaded, check that
>the system hasnt changed. Ive found that (although all the data can be
>faked) that the browser string alone causes alot of grief - especially as
>IE's browser string is changed by many plugin programs.
>
>Just a thought.
>

Unfortunately, this info gets obscured by many major (aol) proxy farms 
as well.

>
>
>




-- 
PHP Development Mailing List 
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP-DEV] trans-sid warning?

2002-08-20 Thread George Schlossnagle

Dan Hardiker wrote:

>>It is also very conceivable that a person would send a link to a java
>>applet or any other kind of wrapper (PHP or other CGI actually would be
>>able to establish the connection on the server side always sending the
>>same user agent string and sending back the data from your site) to
>>establish the session in which case this is rendered useless.
>>
>
>So because its not flawless, we shouldnt try to get as close to perfection
>as we can?
>
>I know its not water-tight by any stretch of the imagination, but the more
>checking in there, the harder it is for hackers to get the foot in the
>door and penetrate. The more abstract the system is (especially on a site
>by site basis) the more work a cracker has to do to work out how a host is
>authenticated.
>

To me this thread has two main issues:

1) don't false advertise:  I agree that most of these methods are good 
steps in the right direction, but it's also important (IMHO) to not 
label them as 'completely secure'.  I think that is misleading. 
 Labeling them as 'good', 'better', 'best available' is swell (and 
should be done - people need to know the best course of action), but 
none of them are perfect, and it's important to note that.

2) False-positives suck: Validating session auth based of ip or 
user_agent permanency will simply not work.  People coming from places 
like AOL will light up your logs with warnings about potential session 
hijacking.  To me, this is really bad.  It clutters the logs with a lot 
of false-positive security violations, making it even harder to detect 
the real ones.  We tried user_agent matching at my last shop.  We were 
getting 10-20 alerts a second while we had it on.  Largely from aol.

George




-- 
PHP Development Mailing List 
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP-DEV] Re: [rfc] apache_hooks update (yet incomplete)

2002-08-26 Thread George Schlossnagle

Here's an incremental patch on Lukas' patch which tries to address a 
couple issues:

o  The startup sequence has been changed to allow for post-data to make 
it through if any hooks before full post-data is read are called
o  works under register_globals Off ($request is now available in the 
SERVER var hash when register globals is enabled)
o  all hooks and the 'main' content handler all share a common scope 
(there is only one call to zend_startup, and only one shutdown).  This 
is significantly cheaper plus it allows for handy stuff like creating 
data structures in a hook and magicall passing them to other hooks or 
into the main script.  This is experimental and may break some of the 
other sapi modules as-is (though that clearly wasn't the intention ;)

George


Lukas Schroeder wrote:

>hi,
>
>here's another shot of the current apache_hooks code.
>
>there are some issues with startup and cleanup currently.
>and the patch messes a bit with php's startup procedure.
>
>still missing is access to array_header (think headers_in, headers_out,
>headers_err) and table slot in request_rec, as is access to the
>whole connection structure of the request.
>
>but the string and int fields can be read and where appropriate written
>to. and there are some methods that wrap the ap_ family.
>
>
>
>regards,
>  -lukas
>




diff -u3 -r php4-lucas3/main/SAPI.c php4-george/main/SAPI.c
--- php4-lucas3/main/SAPI.c Mon Aug 26 11:44:12 2002
+++ php4-george/main/SAPI.c Mon Aug 26 12:05:51 2002
@@ -382,6 +382,7 @@
SG(sapi_headers).mimetype = NULL;
}
sapi_send_headers_free(TSRMLS_C);
+SG(sapi_started) = 0;
 }
 
 
diff -u3 -r php4-lucas3/main/SAPI.h php4-george/main/SAPI.h
--- php4-lucas3/main/SAPI.h Mon Aug 26 11:44:12 2002
+++ php4-george/main/SAPI.h Mon Aug 26 12:04:04 2002
@@ -117,6 +117,7 @@
HashTable *rfc1867_uploaded_files;
long post_max_size;
 int options;
+zend_bool sapi_started;
 } sapi_globals_struct;
 
 
diff -u3 -r php4-lucas3/main/main.c php4-george/main/main.c
--- php4-lucas3/main/main.c Mon Aug 26 11:45:03 2002
+++ php4-george/main/main.c Mon Aug 26 12:42:10 2002
@@ -816,54 +816,52 @@
 /* {{{ php_request_startup
  */
 int php_request_startup(TSRMLS_D)
-{
-   int retval = SUCCESS;
-
+{   
+int retval = SUCCESS;
 #if PHP_SIGCHILD
-   signal(SIGCHLD, sigchld_handler);
-#endif
-
-   zend_try {
-   PG(during_request_startup) = 1;
-   
-   php_output_activate(TSRMLS_C);
-
-   /* initialize global variables */
-   PG(modules_activated) = 0;
-   PG(header_is_being_sent) = 0;
-   PG(connection_status) = PHP_CONNECTION_NORMAL;
-   
-   zend_activate(TSRMLS_C);
-   sapi_activate(TSRMLS_C);
-
-   zend_set_timeout(EG(timeout_seconds));
-
-   if (PG(expose_php)) {
-   sapi_add_header(SAPI_PHP_VERSION_HEADER, 
sizeof(SAPI_PHP_VERSION_HEADER)-1, 1);
-   }
-
-   if (PG(output_handler) && PG(output_handler)[0]) {
-   php_start_ob_buffer_named(PG(output_handler), 0, 1 TSRMLS_CC);
-   }
-   else if (PG(output_buffering)) {
-   php_start_ob_buffer(NULL, 0, 1 TSRMLS_CC);
-   }
-   else if (PG(implicit_flush)) {
-   php_start_implicit_flush(TSRMLS_C);
-   }
-
-   /* We turn this off in php_execute_script() */
-   /* PG(during_request_startup) = 0; */
-
-   php_hash_environment(TSRMLS_C);
-   zend_activate_modules(TSRMLS_C);
-   PG(modules_activated)=1;
-   } zend_catch {
-   retval = FAILURE;
-   } zend_end_try();
+signal(SIGCHLD, sigchld_handler);
+#endif  
+if(!SG(sapi_started)) {
+zend_try {
+PG(during_request_startup) = 1;
+
+/* initialize global variables */
+PG(modules_activated) = 0;
+PG(header_is_being_sent) = 0;
+PG(connection_status) = PHP_CONNECTION_NORMAL;
+
+zend_activate(TSRMLS_C);
+zend_set_timeout(EG(timeout_seconds));
+zend_activate_modules(TSRMLS_C);
+PG(modules_activated)=1;
+} zend_catch {
+retval = FAILURE;
+} zend_end_try();
+SG(sapi_started) = 1;
+}   
+php_output_activate(TSRMLS_C);
+sapi_activate(TSRMLS_C);
+php_hash_environment(TSRMLS_C);
+zend_try {
+if (PG(expose_php)) {
+sapi_add_header(SAPI_PHP_VERSION_HEADER, 
+sizeof(SAPI_PHP_VERSION_HEADER)-1, 1);
+}
+if (PG(output_handler) && PG(output_handler)[0]) {
+php_start_ob_buffer_named(PG(output_handler), 0, 1 TSRMLS_CC);
+}
+else if (PG(output_buffering)) {
+php_start_ob_buffer

Re: [PHP-DEV] Re: [rfc] apache_hooks update (yet incomplete)

2002-08-26 Thread George Schlossnagle

All of this work was off HEAD.  Should a  new_apache_hooks branch be tagged?

Rasmus Lerdorf wrote:

>I say commit it.  This stuff is very experimental as it is and lives in
>its own branch.  You are not going to destabilize anything.
>
>(I just made sure you had enough karma for the commit)
>
>-Rasmus
>



-- 
PHP Development Mailing List 
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP-DEV] Re: [rfc] apache_hooks update (yet incomplete)

2002-08-26 Thread George Schlossnagle

I wasn't proposing putting it in HEAD, just that the work was done 
against HEAD not against your apache_hooks.  Lukas redid all the 
php<->apache request object work fresh off of head, and I made changes 
off of that, so it contains nothing from your apache_hooks branch.

Rasmus Lerdorf wrote:

>I think if we put this in 4.3 we are going to delay 4.3 even further.
>Although, I suppose if we are careful and make sure we #ifdef it nicely
>and only turn it on with a configure option, we can put it in HEAD.
>
>So, is your patch my apache_hooks stuff + Lukas's work and then your stuff
>on top?
>
>On Mon, 26 Aug 2002, George Schlossnagle wrote:
>
>>All of this work was off HEAD.  Should a  new_apache_hooks branch be tagged?
>>
>>Rasmus Lerdorf wrote:
>>
>>>I say commit it.  This stuff is very experimental as it is and lives in
>>>its own branch.  You are not going to destabilize anything.
>>>
>>>(I just made sure you had enough karma for the commit)
>>>
>>>-Rasmus
>>>
>>
>
>




-- 
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP-DEV] Re: [rfc] apache_hooks update (yet incomplete)

2002-08-26 Thread George Schlossnagle

Lukas Schroeder wrote:

>On Mon, Aug 26, 2002 at 11:18:38AM -0700, Rasmus Lerdorf wrote:
>
>>>Well, after 4.3.0 is branched I guess the next release would be
>>>PHP 5 so it's not that far away. If only Stig would start with the
>>>branch :) Anyway, I'm more in favor of having this nice hook stuff
>>>in a seperate branch than with 'magic' things like setting defines.
>>>
>>We can do that, it's just more work to keep it current and as we all know,
>>merging branches in CVS just is not a good thing to do.
>>
>
>i offer to do the ugly work.
>i put it into the branch for now, so i dont even have to think i tiny
>bit about breaking anything. and if time comes, i'll prepare the
>necessary patch sets to merge into the php5 branch, without having to
>use the dreaded cvs merge branch 'feature'.
>
>would that be a deal?
>if so, i'll commit it to apache_hooks today...
>

I actually just made a 'new_apache_hooks' branch and am about to commit 
it all there




-- 
PHP Development Mailing List 
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP-DEV] Re: [rfc] apache_hooks update (yet incomplete)

2002-08-26 Thread George Schlossnagle

I haven't committed anything yet.  It seems like the benefit of starting 
with a fresh copy of HEAD is taht, well, it's a fresh copy of HEAD. 
 Since there is nothing used from the old apache_hooks branch it makes 
sense to me to start afresh.  new name/old name makes no difference to me.

Lukas Schroeder wrote:

>On Mon, Aug 26, 2002 at 02:59:01PM -0400, George Schlossnagle wrote:
>
>>I actually just made a 'new_apache_hooks' branch and am about to commit 
>>it all there
>>
>
>argh. so, what now?
>i don't like having two branches for this.
>
>
>
>




-- 
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP-DEV] Re: [rfc] apache_hooks update (yet incomplete)

2002-08-26 Thread George Schlossnagle

If you want to pull everything into the apche_hooks branch, I can do 
that as well.  But if we do that, it would probably wise to update 
everything in that branch to HEAD.


George Schlossnagle wrote:

> I haven't committed anything yet.  It seems like the benefit of 
> starting with a fresh copy of HEAD is taht, well, it's a fresh copy of 
> HEAD. Since there is nothing used from the old apache_hooks branch it 
> makes sense to me to start afresh.  new name/old name makes no 
> difference to me.
>
> Lukas Schroeder wrote:
>
>> On Mon, Aug 26, 2002 at 02:59:01PM -0400, George Schlossnagle wrote:
>>
>>> I actually just made a 'new_apache_hooks' branch and am about to 
>>> commit it all there
>>>
>>
>> argh. so, what now?
>> i don't like having two branches for this.
>>
>>
>>
>>
>
>
>
>




-- 
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP-DEV] Re: [rfc] apache_hooks update (yet incomplete)

2002-08-26 Thread George Schlossnagle

Ok, this has all been added to the apache_hooks branch, which is now 
up-to-date.

George Schlossnagle wrote:

> If you want to pull everything into the apche_hooks branch, I can do 
> that as well.  But if we do that, it would probably wise to update 
> everything in that branch to HEAD.
>
>
> George Schlossnagle wrote:
>
>> I haven't committed anything yet.  It seems like the benefit of 
>> starting with a fresh copy of HEAD is taht, well, it's a fresh copy 
>> of HEAD. Since there is nothing used from the old apache_hooks branch 
>> it makes sense to me to start afresh.  new name/old name makes no 
>> difference to me.
>>
>> Lukas Schroeder wrote:
>>
>>> On Mon, Aug 26, 2002 at 02:59:01PM -0400, George Schlossnagle wrote:
>>>
>>>> I actually just made a 'new_apache_hooks' branch and am about to 
>>>> commit it all there
>>>>
>>>
>>> argh. so, what now?
>>> i don't like having two branches for this.
>>>
>>>
>>>
>>>
>>
>>
>>
>>
>
>
>
>




-- 
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP-DEV] adding persistent toggle to zend_stack implementation

2002-08-27 Thread George Schlossnagle

Hi,

I'd like to use the zend_stack stuff for stacked handlers in the new 
apache_hooks sapi stuff, but right now, it emalloc's everything, which 
is unacceptable for my usage.  I could write my own stack implementation 
just for the sapi stuf, but thats seems less productive than making 
zend_stack more universally useable.

I've added a persistent attribute to the struct so that it behaves more 
like zend_hash, added a zend_stack_init_ex which allows setting of this 
flag, and #define'd zend_stack_init to do a non-persistent 
zend_stack_init_ex.  Patches are attached.

If this is somehow undesireable, please let me know and I will just 
reimplement stacks for sapi.

George




Index: Zend/zend_stack.c
===
RCS file: /repository/Zend/zend_stack.c,v
retrieving revision 1.11
diff -u -3 -r1.11 zend_stack.c
--- Zend/zend_stack.c   6 Jan 2002 15:21:09 -   1.11
+++ Zend/zend_stack.c   27 Aug 2002 15:15:37 -
@@ -21,10 +21,11 @@
 #include "zend.h"
 #include "zend_stack.h"
 
-ZEND_API int zend_stack_init(zend_stack *stack)
+ZEND_API int zend_stack_init_ex(zend_stack *stack, int persistent)
 {
stack->top = 0;
-   stack->elements = (void **) emalloc(sizeof(void **) * STACK_BLOCK_SIZE);
+stack->persistent = persistent;
+   stack->elements = (void **) pemalloc(sizeof(void **) * STACK_BLOCK_SIZE,  
+persistent);
if (!stack->elements) {
return FAILURE;
} else {
@@ -36,13 +37,13 @@
 ZEND_API int zend_stack_push(zend_stack *stack, void *element, int size)
 {
if (stack->top >= stack->max) { /* we need to allocate more memory */
-   stack->elements = (void **) erealloc(stack->elements,
-  (sizeof(void **) * (stack->max += 
STACK_BLOCK_SIZE)));
+   stack->elements = (void **) perealloc(stack->elements,
+  (sizeof(void **) * (stack->max += 
+STACK_BLOCK_SIZE)), stack->persistent);
if (!stack->elements) {
return FAILURE;
}
}
-   stack->elements[stack->top] = (void *) emalloc(size);
+   stack->elements[stack->top] = (void *) pemalloc(size, stack->persistent);
memcpy(stack->elements[stack->top], element, size);
return stack->top++;
 }
@@ -63,7 +64,7 @@
 ZEND_API int zend_stack_del_top(zend_stack *stack)
 {
if (stack->top > 0) {
-   efree(stack->elements[--stack->top]);
+   pefree(stack->elements[--stack->top], stack->persistent);
}
return SUCCESS;
 }
@@ -96,11 +97,11 @@
register int i;
 
for (i = 0; i < stack->top; i++) {
-   efree(stack->elements[i]);
+   pefree(stack->elements[i], stack->persistent);
}
 
if (stack->elements) {
-   efree(stack->elements);
+   pefree(stack->elements, stack->persistent);
}
return SUCCESS;
 }
Index: Zend/zend_stack.h
===
RCS file: /repository/Zend/zend_stack.h,v
retrieving revision 1.13
diff -u -3 -r1.13 zend_stack.h
--- Zend/zend_stack.h   6 Jan 2002 15:21:09 -   1.13
+++ Zend/zend_stack.h   27 Aug 2002 15:15:37 -
@@ -22,14 +22,14 @@
 #define ZEND_STACK_H
 
 typedef struct _zend_stack {
-   int top, max;
+   int top, max, persistent;
void **elements;
 } zend_stack;
 
 
 #define STACK_BLOCK_SIZE 64
-
-ZEND_API int zend_stack_init(zend_stack *stack);
+#define zend_stack_init(a) zend_stack_init_ex(a, 0);
+ZEND_API int zend_stack_init_ex(zend_stack *stack, int persistent);
 ZEND_API int zend_stack_push(zend_stack *stack, void *element, int size);
 ZEND_API int zend_stack_top(zend_stack *stack, void **element);
 ZEND_API int zend_stack_del_top(zend_stack *stack);



-- 
PHP Development Mailing List 
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP-DEV] Re: [rfc] apache_hooks update (yet incomplete)

2002-08-27 Thread George Schlossnagle

A little update on all of this.

I changed the way that the handlers are created in the apache config from

php_value uri_handler /tmp/foo.php
to
phpUriHandler /tmp/foo.php

and logically separated them from the ini structure.  This eliminates 
some unnecessary work that was being done before and allows for stacked 
handlers more easily.  I have the stacked handler code all working 
correctly, but I'm waiting on approval/disapproval of my zend_stack 
patch I posted earlier before I commit (my changes assume that patch at 
the moment).  A couple new things are supported as well

phpRequire /tmp/bar.php

which effectively 'require's a file before any work is done in a request 
(since scope is shared throughout all stages of the request this is 
available everywhere). And

phpResponseHandler /tmp/foofoo.php

Which is a very experimental AddHandler response-time handler (similair 
to perl PerlHandler)

Both of these are stackable, so you can do

phpRequire /tmp/bar.php
phpRequire /tmp/bar2.php

in the same section and have them both run (same for all the handlers).

I will wait a while to see if the zend_stack changes are accepted, if 
not I will just implement my own stack locally and use that instead.

George



Edin Kadribasic wrote:

>>Ok, this has all been added to the apache_hooks branch, which is now
>>up-to-date.
>>
>
>Very nice. IMHO this should be merged into HEAD as soon as PHP_4_3_0 is
>branched off.
>
>Edin
>
>




-- 
PHP Development Mailing List 
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP-DEV] Re: cgi and mod_php

2002-08-28 Thread George Schlossnagle

Daniel Lorch wrote:

>hi,
>
>>>Yes, it would look like this:
>>>
>>>1. ./configure 
>>>2. make
>>>3. make clean
>>>4. goto 1
>>>
>>>- Sascha
>>>
>>So we do not have the possibility to build all three without
>>make clean in one go. I would very much appreciate that
>>since it would make developers life much easier...
>>
>
>Use the force, luke.
>
>  #!/bin/bash
>
>  for mode in apache cli cgi; do
>./configure --with-${mode}
>make
>make clean
>  done
>
>Maybe this script doesn't work, but you get the idea :)
>

I think the point isn't that it's not scriptable, but that it would be 
nice if there was a 'canned' way of doing it.  I use the apache sapi and 
the cli, and it would be nice to be able to build them with a single 
make.  Clearly there are ways to build them both (easily), but it should 
be easy for a basic user to have it build multiple targets.  This is 
especially true with the cli, as there are abundant reasons to have it 
and one of the web-centric sapi's cohabitating on a system.

George




-- 
PHP Development Mailing List 
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP-DEV] Re: cgi and mod_php

2002-08-28 Thread George Schlossnagle

It sure does seem to, doesn't it.  ;)


Mike Hall wrote:

>I'm sure PHP 4.3.0 builds the CLI as well as any other SAPI you specify,
>doesn't it?
>
>- Original Message -
>From: "George Schlossnagle" <[EMAIL PROTECTED]>
>To: "Daniel Lorch" <[EMAIL PROTECTED]>
>Cc: <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]>;
><[EMAIL PROTECTED]>
>Sent: Wednesday, August 28, 2002 9:54 PM
>Subject: Re: [PHP-DEV] Re: cgi and mod_php
>
>
>>I think the point isn't that it's not scriptable, but that it would be
>>nice if there was a 'canned' way of doing it.  I use the apache sapi and
>>the cli, and it would be nice to be able to build them with a single
>>make.  Clearly there are ways to build them both (easily), but it should
>>be easy for a basic user to have it build multiple targets.  This is
>>especially true with the cli, as there are abundant reasons to have it
>>and one of the web-centric sapi's cohabitating on a system.
>>
>
>
>




-- 
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP-DEV] anyone care to poke holes in the apache_hooks stuff

2002-08-30 Thread George Schlossnagle

The apache_hooks stuff is about at the stage where people poking 
holes/finding bugs/making suggestions would be very beneficial.  Any 
feedback would be appreciated.

// George Schlossnagle
// Principal Consultant
// OmniTI, Inc  http://www.omniti.com
// (c) 240.460.5234   (e) [EMAIL PROTECTED]
// 1024D/1100A5A0  1370 F70A 9365 96C9 2F5E 56C2 B2B9 262F 1100 A5A0


-- 
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP-DEV] anyone care to poke holes in the apache_hooks stuff

2002-08-30 Thread George Schlossnagle

Sure.

First to build it, you will need to check out HEAD and update 
main/main.c main/SAPI.* and sapi/apache/* to the apache_hooks branch.  
Now you can register handlers for any of the apache request api hooks.   
Valid httpd.conf commands are:

phpRequire /path/to/file  = requires a file at the beginning of an 
initial apache request

phpUriHandler /path/to/file  = registers a hook that will run the 
specified file at the uri translation stage of the apache request
phpUriHandler Class::Method = registers a hook to run  Class::Method at 
the uri translation stage of the apache request

phpPostReadHandler /path/to/file = hook for post-read phase
phpPostReadHandlerMethod Class::Method

phpHeaderHandler  = hook for header parsing phase
phpHeaderHandlerMethod

phpAuthHandler = hook for authentication phase
phpAuthHandlerMethod

phpAccessHandler = hook for access control phase
phpAccessHandlerMethod

phpTypeHandler = hook for Type Checking phase
phpTypeHandlerMethod

phpFixupHandler = hook for 'fixup' phase
phpFixupHandlerMethod

phpLoggerHandler = hook for logging phase
phpLoggerHandlerMethod

AddHandler php-script   =  set's up a special type handler
phpResponseHandler  /path/to/file  = sets file to be called to handle 
response phase
phpResponseHandlerMethod Class::Method

So, to set up a 'hello world' location handler (so that any request to 
/hello/* returns hello world) you can:

phpRequire /tmp/setup.php

AddHandler php-script
phpResponseHandlerMethod Hello::World


with
#/tmp/setup.php
send_http_header();
 echo "Hello World";
 }
}
?>

$request is the apache request.  It is instantiated at all stages 
automatically.  The methods of that class are:

getallheaders
args
boundary
content_encoding
content_type
filename
handler
hostname
method
path_info
protocol
status_line
the_request
unparsed_uri
uri
allowed
bytes_sent
chunked
content_length
header_only
method_number
mtime
no_cache
no_local_copy
proto_num
proxyreq
read_body
remaining
request_time
status
headers_in
headers_out
err_headers_out
auth_name
auth_type
basic_auth_pw
discard_request_body
is_initial_req
meets_conditions
remote_host
satisfies
server_port
set_etag
set_last_modified
some_auth_required
update_mtime
send_http_header
basic_http_header
send_header_field
send_http_trace
send_http_options
send_error_response
set_content_length
set_keepalive
rputs
log_error
lookup_uri
lookup_file
method_uri
run
internal_redirect


These all wrap the ap_* apache EXPORT_API functions using the same 
semantics (and are also the same as the Apache::Request methods in 
mod_perl if you are familiar with that)

So, a uri handler to redirect all non-local traffic to /404.php (an 
error page) would be

phpUriHandler  /tmp/uri.php

#/tmp/uri.php
uri('/404.php');
}
return OK;
?>

It's important to note that since this is called from the uri 
translations phase, this validation is performed for every request to 
the server, not just for php pages.

Also, scope is shared between all the hooks.  So in the above, we could 
merge the two and do something like:

#/tmp/uri.php


and then:

#/tmp/setup.php
send_http_header();
 echo "Hello $whoami";
 }
}
?>

These variables are also in the same scope as a script if your script is 
being handled by the standard application/x-httpd-php handler.

This allows you to make decisions and pass data between your handlers 
and scripts at all stages.

The above are clearly trite examples, but hopefully give you a starting 
point.

One note:  all handlers can be validly re-entered 'in sub-requests'.  
For this reason you should not define functions/classes here without 
anti-redefinition guards (I would just recommend putting them in an 
include and using include_one).  This is not true for phpRequire, which 
is only entered once, at the main request, and so it is safe to make 
function/class declarations there (in fact that's what it's for).

Hope that helps!

George

On Friday, August 30, 2002, at 03:31 PM, Edin Kadribasic wrote:

>> The apache_hooks stuff is about at the stage where people poking
>> holes/finding bugs/making suggestions would be very beneficial.  Any
>> feedback would be appreciated.
>
> apache_hooks stuff sounds very interesting, but it's kind of difficult 
> start
> playing with it without any pointers. Could you give us some hints/usage
> tips on how to get started?
>
> Edin
>
>
>
> --
> PHP Development Mailing List <http://www.php.net/>
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
>
// George Schlossnagle
// Principal Consultant
// OmniTI, Inc  http://www.omniti.com
// (c) 240.460.5234   (e) [EMAIL PROTECTED]
// 1024D/1100A5A0  1370 F70A 9365 96C9 2F5E 56C2 B2B9 262F 1100 A5A0


-- 
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP-DEV] dl() question

2002-09-18 Thread George Schlossnagle

Is there a reason why dl() does not support absolute paths for so's?  
I'm writing an Inline_C extension (similar to perl's Inline::C), that 
compiles functions on the fly.  Obviously allowing the webserver to 
write to your extensions dir is a problem, but dl() (which is needed to 
load the on-the-fly-generated module) seems only to read from there.  Is 
there a good reason for taht, and if not, would a patch to allow dl() to 
take absolute paths be looked upon favorably?

George

// George Schlossnagle
// Principal Consultant
// OmniTI, Inc  http://www.omniti.com
// (c) 240.460.5234   (e) [EMAIL PROTECTED]
// 1024D/1100A5A0  1370 F70A 9365 96C9 2F5E 56C2 B2B9 262F 1100 A5A0


-- 
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP-DEV] php/embed

2002-09-28 Thread George Schlossnagle

very cool.

On Saturday, September 28, 2002, at 10:56 PM, Edin Kadribasic wrote:

> Hello,
>
> I have just committed initial work on enabling embedding PHP into C/C++
> applications. It is mostly complete, but there a few pieces missing, 
> namely
> the installation part. The modification of the build system adds another
> target, so in order to test the new functionality you need to configure 
> php
> in the usual manner, and then do "make", "make install" and "make libs".
> Since libs are not installed by "make install" you need to copy 
> libphp.so
> manually to appropriate directory.
>
> The best way to explain how this works is to show you some code 
> examples.
>
> pembed.c
> 
> #include 
>
> int main(int argc, char **argv)
> {
>   char *php_code = "echo \"Hello, World!\\n\";";
>
>   PHP_EMBED_START_BLOCK(argc, argv);
>   zend_eval_string(php_code, NULL, "Embedded code" TSRMLS_CC);
>   PHP_EMBED_END_BLOCK();
>
>   return 0;
> }
>
> Makefile (unix)
> ===
> LIBS=-lphp $(shell php-config --libs)
> INCLUDES=$(shell php-config --includes)
> LIBDIRS=-L$(shell php-config --prefix)/lib
> PHP_EXE=$(shell php-config --prefix)/bin/php
> CC=gcc
> CFLAGS=-g -Wall
>
> pembed: pembed.o
> $(CC) $(CFLAGS) $(LIBDIRS) -o pembed $(LIBS) pembed.o
>
> pembed.o: pembed.c
> $(CC) $(CFLAGS) $(INCLUDES) -c pembed.c
>
> clean:
> rm -f *.o pembed
>
> Makefile (win32)
> 
> # Put your compiled php source here
> ROOT=u:\projects\php\php4.sdk
> LIBS=php4ts.lib phpembed.lib
> INCLUDES=-I "$(ROOT)" -I "$(ROOT)\main" -I "$(ROOT)\Zend" -I 
> "$(ROOT)\TSRM"
> LIBDIRS=/libpath:"$(ROOT)\Release_TS"
> CC=cl
> LD=link
> CFLAGS=-MD -D ZTS -D PHP_WIN32 -D ZEND_WIN32
>
> pembed.exe: pembed.obj
> $(LD) $(LIBDIRS) /out:pembed.exe $(LIBS) pembed.obj
>
> pembed.obj: pembed.c
> $(CC) $(CFLAGS) $(INCLUDES) -c pembed.c
>
> clean:
> -del *.obj
> -del pembed.exe
>
>
> As you can see from the example pembed.c file it is not very difficult 
> to get
> the PHP engine started using php/embed. There are some things that you 
> need
> to notice: you should think of PHP_EMBED_START_BLOCK() and
> PHP_EMBED_END_BLOCK() as {} block, so take care not to intersect with 
> other
> {} blocks. If this is too great a limitiation, functions
>
> int php_embed_init(int argc, char **argv PTSRMLS_DC);
> void php_embed_shutdown(TSRMLS_D);
>
> should be used instead.
>
> I'm looking forward to your feedback and help to get the "make install" 
> part
> working.
>
> Edin
>
>
> --
> PHP Development Mailing List <http://www.php.net/>
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
>
// George Schlossnagle
// Principal Consultant
// OmniTI, Inc  http://www.omniti.com
// (c) 240.460.5234   (e) [EMAIL PROTECTED]
// 1024D/1100A5A0  1370 F70A 9365 96C9 2F5E 56C2 B2B9 262F 1100 A5A0


-- 
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP-DEV] auto_prepend/append: does the PHP engine cache the

2002-09-29 Thread George Schlossnagle

Just as a note about all this: if you have a deep 'standard' include 
tree (same 30-40 files), there is a decent amount of overhead just from  
parsing all the include files, even with inexpensive code.

> Your OS should do a reasonable job (or a really good job if it's Unix 
> based)
> at caching the file contents and the ZE is pretty fast at spotting 
> inline
> HTML in your php files, so I wouldn't worry so much about the 
> performance
> of this aspect, unless you have some real CPU-intensive code in your
> frequently included files, or a large number of hits.
>
> If that is the case, consider using APC (if you don't want to pay 
> money),
> or the Zend Accelerator (if you have some money, or if your site is a
> non-commerical community site - see zend.com for details).
>
> --Wez.
>
>
> --
> PHP Development Mailing List <http://www.php.net/>
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
>
// George Schlossnagle
// Principal Consultant
// OmniTI, Inc  http://www.omniti.com
// (c) 240.460.5234   (e) [EMAIL PROTECTED]
// 1024D/1100A5A0  1370 F70A 9365 96C9 2F5E 56C2 B2B9 262F 1100 A5A0


-- 
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP-DEV] Segfaults in Zend

2002-10-14 Thread George Schlossnagle

Can you give the source for that function and the arguments it's being 
passed/context it is used in?

Jan Schneider wrote:

>Zitat von Yasuo Ohgaki <[EMAIL PROTECTED]>:
>
>>>0x4055778f in _efree (ptr=0x83476e4)
>>>at /home/jan/software/php4/Zend/zend_alloc.c:229
>>>229 REMOVE_POINTER_FROM_LIST(p);
>>>(gdb) bt
>>>#0  0x4055778f in _efree (ptr=0x83476e4)
>>>at /home/jan/software/php4/Zend/zend_alloc.c:229
>>>#1  0x405664a1 in _zval_dtor (zvalue=0x83456bc)
>>>at /home/jan/software/php4/Zend/zend_variables.c:44
>>>#2  0x4055e4c1 in _zval_ptr_dtor (zval_ptr=0x40605714)
>>>at /home/jan/software/php4/Zend/zend_execute_API.c:293
>>>#3  0x4057516d in execute (op_array=0x835c0c4)
>>>
>>If you could tell us what execute() is trying to execute,
>>it would be useful.
>>
>
>(gdb) frame 3
>#3  0x4057516d in execute (op_array=0x8353ebc)
>at /home/jan/software/php4/Zend/zend_execute_locks.h:26
>26  zval_ptr_dtor(&EG(garbage)[--EG(garbage_ptr)]);
>(gdb) print (char
>*)(executor_globals.function_state_ptr->function)->common.function_name
>$1 = 0x82f313c "flist"
>
>flist() is the function mentioned earlier, that segfaults while returning to
>the calling function.
> 
>
>>Did you read my email? (and the URL?)
>>http://bugs.php.net/bugs-generating-backtrace.php
>>
>
>Sorry, I didn't know that it has been updated with instructions on how to
>locate the segfaulting function.
>
>Jan.
>
>--
>http://www.horde.org - The Horde Project
>http://www.ammma.de - discover your knowledge
>http://www.tip4all.de - Deine private Tippgemeinschaft
>




-- 
PHP Development Mailing List 
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP-DEV] Feature ./ correction to design flaw request

2002-10-14 Thread George Schlossnagle

One reason would be to allow for a product like APD to do JIT swapping 
of executors to enable tracing on demand.  I imagine you could come up 
with a clever way of letting Zend (En|De)coder be used for oly prticular 
clients in a large vhosting operation as well (although I don't really 
know how that product works.)

George

Andi Gutmans wrote:

> If there's no concrete reason it is needed I think things should stay 
> as they are.
> One reason - it's slower, probably not noticeable but it still is.
>
> Andi
>
> At 03:06 PM 10/14/2002 +0100, Nick Lindridge wrote:
>
>> >why would one want to have different executors/compilers in
>> >different threads?
>>
>> I can't answer this question Thies, and one could achieve it as-is by
>> having a thread safe delegator, but as far as possible I'd suggest that
>> publicly exposed features of the engine should work across supported
>> platforms, and isn't the case with these hooks.
>>
>> I remember the days when myself and other kids were writing machine
>> code non-flicker software on Sinclair ZX80's, and that was thought of
>> as 'impossible' (as the CRT hardware was driven by software and any
>> operations caused flicker), but actually this was possible if you'd a
>> Z80 handbook to hand and didn't mind counting instruction cyles on all
>> the possible branch paths, and pulled some tricks.
>>
>> This is just in my view and experience, but people will always use
>> features and do things that designers of said features could never have
>> conceived. Equally people will solve problems in different ways to
>> others, and one has to mindful of this and accordingly endeavour to
>> design without artificial constraints. If one knows that modifiable
>> globals should be made thread safe on a threaded server then unless
>> there's a good reason to not do it, it should be done, and not omitted
>> just because the developer 'didn't think that it would be useful'.
>> Genuine omissions, as was probably the case here, are fine, and we all
>> make them, but should then be scheduled for correction once discovered
>> for the benefit of future developments, and to improve the quality of
>> the product as a whole.
>>
>>
>>
>>
>>
>> -- 
>> PHP Development Mailing List 
>> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
>




-- 
PHP Development Mailing List 
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP-DEV] Feature ./ correction to design flaw request

2002-10-14 Thread George Schlossnagle

As I just told Nick in private mail, I personally like my bubble.  It 
has nice translucent walls, keeps me dry when it's wet, and warm when 
it's cold.

All talk of bubbles aside though it seems like there are potential 
applications for this.

Andi Gutmans wrote:

> At 09:49 PM 10/14/2002 +0100, Nick Lindridge wrote:
>
>> > One reason would be to allow for a product like APD to do JIT swapping
>> > of executors to enable tracing on demand.  I imagine you could come up
>> > with a clever way of letting Zend (En|De)coder be used for oly
>> > prticular  clients in a large vhosting operation as well (although I
>> > don't really  know how that product works.)
>>
>> Bingo! Well done George :) Nice to see someone thinking beyond their
>> bubble.
>
>
> Thanks for the compliment.
>
> Andi
>
>




-- 
PHP Development Mailing List 
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP-DEV] Xerces?

2002-10-16 Thread George Schlossnagle

Has anyone started any work work on this?

On Wednesday, October 16, 2002, at 05:59 PM, Rasmus Lerdorf wrote:

> There is only Sablotron support.  No Xerces.  Feel free to contribute 
> the
> code to support Xerces.
>
> -Rasmus
>
> On Wed, 16 Oct 2002, Alex Black wrote:
>
>> Hi all,
>>
>> I have done limited looking but as far as I can tell Xerces is not 
>> supported
>> by PHP.
>>
>> A) hopefully I am wrong and just didn't look hard enough.
>> B) If not, any validating parsers that are supported that do DTD 
>> validation?
>>
>> It looks like there's an experimental Xalan ext out there, but no 
>> Xerces. I
>> have a vague memory of the XML setup being generalized to allow (x) 
>> parsers,
>> did that happen, etc?
>>
>> In any case, if there aren't any validating parsers supported by PHP...
>> There should be :)
>>
>> Please respond to the binarycloud-dev list also...
>>
>> Thanks,
>>
>> _alex
>>
>>
>> --
>> PHP Development Mailing List <http://www.php.net/>
>> To unsubscribe, visit: http://www.php.net/unsub.php
>>
>
>
> --
> PHP Development Mailing List <http://www.php.net/>
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
// George Schlossnagle
// Principal Consultant
// OmniTI, Inc  http://www.omniti.com
// (c) 240.460.5234   (e) [EMAIL PROTECTED]
// 1024D/1100A5A0  1370 F70A 9365 96C9 2F5E 56C2 B2B9 262F 1100 A5A0


-- 
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP-DEV] RFC: CLI behave like SH or PERL/RUBY/PYTHON?

2002-10-23 Thread George Schlossnagle
I'm not a big fan of doing things the smart way.  How hard is it to just 
set ob_implicit_flush() on and off?  If you want it off, just set it off 
(or on, as the default ends up set) at the head of your script.

George

On Wednesday, October 23, 2002, at 04:11 AM, Kristian Koehntopp wrote:

On Wednesday 23 October 2002 09:41, Edin Kadribasic wrote:

OTOH, having implicit_flush turned on makes writing interactive command
line programs easier. Some programs (like pear installer) might even 
depend
on it.

The proper way around this, as I see it, is to flush at the end of 
line, and
before each read operation on an interactive tty. This would give you
the performance of implicit_flush off with the proper interactive 
behaviour.
I'd like to call this "implicit_flush = smart".

Kristian


--
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, visit: http://www.php.net/unsub.php


// George Schlossnagle
// Principal Consultant
// OmniTI, Inc  http://www.omniti.com
// (c) 240.460.5234   (e) [EMAIL PROTECTED]
// 1024D/1100A5A0  1370 F70A 9365 96C9 2F5E 56C2 B2B9 262F 1100 A5A0


--
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP-DEV] RFC: CLI behave like SH or PERL/RUBY/PYTHON?

2002-10-22 Thread George Schlossnagle
Not to be snarky, but I for one would prefer PHP to behave like PHP.  ;)

Without having to make everyone here sort through the commit messages, 
can you briefly list out the proposed changes?

George

On Wednesday, October 23, 2002, at 02:26 AM, Yasuo Ohgaki wrote:

I thought it's obvious choice, but it seems it's not.

Which one you prefer CLI behave like

SH

or

PERL/RUBY/PYTHON

--
Yasuo Ohgaki


--
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, visit: http://www.php.net/unsub.php



// George Schlossnagle
// Principal Consultant
// OmniTI, Inc  http://www.omniti.com
// (c) 240.460.5234   (e) [EMAIL PROTECTED]
// 1024D/1100A5A0  1370 F70A 9365 96C9 2F5E 56C2 B2B9 262F 1100 A5A0


--
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP-DEV] RFC: CLI behave like SH or PERL/RUBY/PYTHON?

2002-10-22 Thread George Schlossnagle
That statement about character devices being line bufffered isn't quite 
true, but otherwise I would say +0.  Line buffering stdout and 
unbuffering stderr seems to be the default of most languages.




On Wednesday, October 23, 2002, at 02:45 AM, Yasuo Ohgaki wrote:

George Schlossnagle wrote:

Not to be snarky, but I for one would prefer PHP to behave like 
PHP.  ;)
Without having to make everyone here sort through the commit messages, 
can you briefly list out the proposed changes?

Oops. Sorry, I forgot.
It's about flushing output every output statement.

SH and current CLI does fflush() on stdout with
echo "A"

while others don't.
And this setting cannot be changed by php.ini.

User has to pass "-D implicit_flush=Off" as command line option.

As we all know, character devices flushes by newline, so
flushing is not really needed. If user would like to do flush,
flush() function may be used (or change php.ini)

--
Yasuo Ohgaki


George
On Wednesday, October 23, 2002, at 02:26 AM, Yasuo Ohgaki wrote:

I thought it's obvious choice, but it seems it's not.

Which one you prefer CLI behave like

SH

or

PERL/RUBY/PYTHON

-- Yasuo Ohgaki


-- PHP Development Mailing List <http://www.php.net/>
To unsubscribe, visit: http://www.php.net/unsub.php



// George Schlossnagle
// Principal Consultant
// OmniTI, Inc  http://www.omniti.com
// (c) 240.460.5234   (e) [EMAIL PROTECTED]
// 1024D/1100A5A0  1370 F70A 9365 96C9 2F5E 56C2 B2B9 262F 1100 A5A0



-- PHP Development Mailing List <http://www.php.net/>
To unsubscribe, visit: http://www.php.net/unsub.php




--
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP-DEV] I hope this is the last email about this :)

2002-10-27 Thread George Schlossnagle
+1 unless it is set as an INI_ANY, then +0.

George

On Sunday, October 27, 2002, at 09:05 PM, Zeev Suraski wrote:


Thank you for the detailed explanation, I'm sure everybody understands 
it now.

Let's go for the voting phase.  I vote we keep PHP-CLI with 
implicit_flush on by default.  You vote against.

Can we get some other votes now (not opinions, everything was already 
said a dozen times, just votes to get this over with).

Thanks!

Zeev

At 15:11 25/10/2002, Yasuo Ohgaki wrote:
Zeev Suraski wrote:

At 09:15 25/10/2002, Yasuo Ohgaki wrote:


Zeev Suraski wrote:


You print something, it doesn't print out.  How is it trivial to 
solve this?  If you happen to know that there's IO buffering and 
that there's a function called flush() then maybe it trivial, but 
then there are the other million users who don't.  Hence the idea 
of setting is to implicit flush for the masses, who not only don't 
know about the existence of flush(), but also don't know why it's 
even necessary.


Ok. If we are argue about what is mass or not

Don't forget about

 - millions(?) of _current_ PHP users who are used to 
implicit_flush=off by default.

Few of them use CLI.


As I mentioned already, people are used to implicit_off=off and
it's the default of other SAPIs, therefore, it's not intuitive
for existing users.

If we aren't care about much about existing users base,
I think we should set short_tag=Off by default, but you're
insisting it should be on even if much fewer people are
using. I'm confused.

People expects PHP/CLI behave like Apache SAPI, CGI SAPI, etc.

Well, if I weren't developer and didn't know discussion,
I'll certainly write bug report that implicit flush is enabled
wrongly.




 - millions of decent programmers who are used to _usual_ behavior.


I consider myself a decent programmer, and I also consider the need 
to flush explicitly extremely annoying.  Moreover, many PHP 
programmers (if not most) aren't used to this 'usual' behavior, 
because they either never programmed in another language, or they 
still didn't bump into that specific behavior.

Don't you think flushing is needed only very limited applications?
i.e. We don't write interactive CUI applications much now a days.




 - millions of scripts/echo/print don't need automatic flush at all.
   i.e. much fewer number of script/echo/print need auto flushing.


It doesn't matter.  When you're screwed by the lack of implicit 
flush, it's much worse than a mere slow down.

Hmm. Since console is line buffered. There aren't many thing that
is missed by implicit flushing.




Please list programming languages (i.e. not shell) that do
automatic/inefficient/unneeded flushing by default in program mode.


Read my fingertips - PHP IN CLI MODE.  There's one, that's the only 
one I care about.

My point is we should learn from many smart peoples designs' of
languages.




If we are argue about difficulty of flushing,


We're not.  We're arguing about the obscurity of the problem.


implicit_flush=On is obscure for current users.

Suppose "not flushing" is extremely obscure, but default is better
to set which is better/suitable for more occasions and is better to
be consistent with other SAPIs.

Is this the main point of auto flushing?
If there are other points, please list them.

--
Yasuo Ohgaki




-- PHP Development Mailing List <http://www.php.net/>
To unsubscribe, visit: http://www.php.net/unsub.php



// George Schlossnagle
// Principal Consultant
// OmniTI, Inc  http://www.omniti.com
// (c) 240.460.5234   (e) [EMAIL PROTECTED]
// 1024D/1100A5A0  1370 F70A 9365 96C9 2F5E 56C2 B2B9 262F 1100 A5A0


--
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP-DEV] I hope this is the last email about this :)

2002-10-27 Thread George Schlossnagle
That was +1 for changing it to off. :)

On Sunday, October 27, 2002, at 09:37 PM, George Schlossnagle wrote:


+1 unless it is set as an INI_ANY, then +0.

George

On Sunday, October 27, 2002, at 09:05 PM, Zeev Suraski wrote:


Thank you for the detailed explanation, I'm sure everybody understands 
it now.

Let's go for the voting phase.  I vote we keep PHP-CLI with 
implicit_flush on by default.  You vote against.

Can we get some other votes now (not opinions, everything was already 
said a dozen times, just votes to get this over with).

Thanks!

Zeev

At 15:11 25/10/2002, Yasuo Ohgaki wrote:
Zeev Suraski wrote:

At 09:15 25/10/2002, Yasuo Ohgaki wrote:


Zeev Suraski wrote:


You print something, it doesn't print out.  How is it trivial to 
solve this?  If you happen to know that there's IO buffering and 
that there's a function called flush() then maybe it trivial, but 
then there are the other million users who don't.  Hence the idea 
of setting is to implicit flush for the masses, who not only don't 
know about the existence of flush(), but also don't know why it's 
even necessary.


Ok. If we are argue about what is mass or not

Don't forget about

 - millions(?) of _current_ PHP users who are used to 
implicit_flush=off by default.

Few of them use CLI.


As I mentioned already, people are used to implicit_off=off and
it's the default of other SAPIs, therefore, it's not intuitive
for existing users.

If we aren't care about much about existing users base,
I think we should set short_tag=Off by default, but you're
insisting it should be on even if much fewer people are
using. I'm confused.

People expects PHP/CLI behave like Apache SAPI, CGI SAPI, etc.

Well, if I weren't developer and didn't know discussion,
I'll certainly write bug report that implicit flush is enabled
wrongly.




 - millions of decent programmers who are used to _usual_ behavior.


I consider myself a decent programmer, and I also consider the need 
to flush explicitly extremely annoying.  Moreover, many PHP 
programmers (if not most) aren't used to this 'usual' behavior, 
because they either never programmed in another language, or they 
still didn't bump into that specific behavior.

Don't you think flushing is needed only very limited applications?
i.e. We don't write interactive CUI applications much now a days.




 - millions of scripts/echo/print don't need automatic flush at all.
   i.e. much fewer number of script/echo/print need auto flushing.


It doesn't matter.  When you're screwed by the lack of implicit 
flush, it's much worse than a mere slow down.

Hmm. Since console is line buffered. There aren't many thing that
is missed by implicit flushing.




Please list programming languages (i.e. not shell) that do
automatic/inefficient/unneeded flushing by default in program mode.


Read my fingertips - PHP IN CLI MODE.  There's one, that's the only 
one I care about.

My point is we should learn from many smart peoples designs' of
languages.




If we are argue about difficulty of flushing,


We're not.  We're arguing about the obscurity of the problem.


implicit_flush=On is obscure for current users.

Suppose "not flushing" is extremely obscure, but default is better
to set which is better/suitable for more occasions and is better to
be consistent with other SAPIs.

Is this the main point of auto flushing?
If there are other points, please list them.

--
Yasuo Ohgaki




-- PHP Development Mailing List <http://www.php.net/>
To unsubscribe, visit: http://www.php.net/unsub.php



// George Schlossnagle
// Principal Consultant
// OmniTI, Inc  http://www.omniti.com
// (c) 240.460.5234   (e) [EMAIL PROTECTED]
// 1024D/1100A5A0  1370 F70A 9365 96C9 2F5E 56C2 B2B9 262F 1100 A5A0



-- PHP Development Mailing List <http://www.php.net/>
To unsubscribe, visit: http://www.php.net/unsub.php




--
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP-DEV] I hope this is the last email about this :)

2002-10-27 Thread George Schlossnagle
Indeed it appears to be...  +0 then.  :)

On Monday, October 28, 2002, at 07:44 AM, Zeev Suraski wrote:


At 18:37 27/10/2002, George Schlossnagle wrote:

+1 unless it is set as an INI_ANY, then +0.


It's already INI_ANY...


-- PHP Development Mailing List <http://www.php.net/>
To unsubscribe, visit: http://www.php.net/unsub.php



// George Schlossnagle
// Principal Consultant
// OmniTI, Inc  http://www.omniti.com
// (c) 240.460.5234   (e) [EMAIL PROTECTED]
// 1024D/1100A5A0  1370 F70A 9365 96C9 2F5E 56C2 B2B9 262F 1100 A5A0


--
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP-DEV] Re: apache_hooks

2002-11-03 Thread George Schlossnagle
Either way works for me.  Psychologically, I think it may get higher 
exposure if it is #ifdef'd, but I have style reservations about doing 
that.  How has this sort of thing been done in the past?  Is it 
undesirable to fork the apache sapi into a new 'apache_hooks' sapi?  
That may be easiest.

George

On Saturday, November 2, 2002, at 05:58 PM, Rasmus Lerdorf wrote:

What do you think would be the best way to make the apache_hooks code 
more
accessible to people?  A tarball with the relevant files that overwrites
the standard files, or perhaps it is time to #ifdef it into the main
branch?

-Rasmus


// George Schlossnagle
// Principal Consultant
// OmniTI, Inc  http://www.omniti.com
// (c) 240.460.5234   (e) [EMAIL PROTECTED]
// 1024D/1100A5A0  1370 F70A 9365 96C9 2F5E 56C2 B2B9 262F 1100 A5A0


--
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP-DEV] turning strlen() into an opcode

2002-11-09 Thread George Schlossnagle
Here's the patch that Dan and I put together for the optimizer we talked 
about at the conference.  It basically provides a defaulted-to-null 
function pointer that is the default case for the main execute() loop.  
This allows people to define their own opcodes without having to copy 
the source code for execute part and parcel into their own 
zend_execute() just to add a new opcodes.  This is useful both for 
optimizers (like the one now in PECL/optimizer), as well as for 
implementing custom opcodes like what you want here without a huge 
engine patch.

George




On Friday, November 8, 2002, at 05:18 PM, Andrei Zmievski wrote:

On Sat, 09 Nov 2002, Andi Gutmans wrote:

I am very much against anything like this.
Improving strlen()'s performance only will have a negligible 
performance
impact on a real world script.
With the same kind of argument you could probably find 10-20 functions
which would be faster if you'd make opcodes for them. That's not really
what you'd want to do.
Also, the patch isn't quite the same functionality wise because strlen 
in
your patch is a reserved word. This isn't my main problem though as it
could be solved.

Just out of curiousity, what are the problems with making it a reserved
word and how could it be solved?


If you want to really help improve performance of real-world scripts 
then
try and find a way to improve performance of *all* function calls, 
i.e., of
the extension API; and not by moving functions from the extension API 
into
the core.

No big deal. This just came up at the PHP conference in Germany during a
chat with George and Thies.

-Andrei   http://www.gravitonic.com/
* If Bill Gates had a nickel for every time Windows crashed.. Oh, 
wait.. *

--
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, visit: http://www.php.net/unsub.php


// George Schlossnagle
// Principal Consultant
// OmniTI, Inc  http://www.omniti.com
// (c) 240.460.5234   (e) [EMAIL PROTECTED]
// 1024D/1100A5A0  1370 F70A 9365 96C9 2F5E 56C2 B2B9 262F 1100 A5A0


--
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP-DEV] turning strlen() into an opcode

2002-11-09 Thread George Schlossnagle
Hehe.  I should attach the patch, eh?




On Saturday, November 9, 2002, at 09:15 PM, George Schlossnagle wrote:


Here's the patch that Dan and I put together for the optimizer we 
talked about at the conference.  It basically provides a 
defaulted-to-null function pointer that is the default case for the 
main execute() loop.  This allows people to define their own opcodes 
without having to copy the source code for execute part and parcel into 
their own zend_execute() just to add a new opcodes.  This is useful 
both for optimizers (like the one now in PECL/optimizer), as well as 
for implementing custom opcodes like what you want here without a huge 
engine patch.

George




On Friday, November 8, 2002, at 05:18 PM, Andrei Zmievski wrote:

On Sat, 09 Nov 2002, Andi Gutmans wrote:

I am very much against anything like this.
Improving strlen()'s performance only will have a negligible 
performance
impact on a real world script.
With the same kind of argument you could probably find 10-20 functions
which would be faster if you'd make opcodes for them. That's not 
really
what you'd want to do.
Also, the patch isn't quite the same functionality wise because 
strlen in
your patch is a reserved word. This isn't my main problem though as it
could be solved.

Just out of curiousity, what are the problems with making it a reserved
word and how could it be solved?


If you want to really help improve performance of real-world scripts 
then
try and find a way to improve performance of *all* function calls, 
i.e., of
the extension API; and not by moving functions from the extension API 
into
the core.

No big deal. This just came up at the PHP conference in Germany 
during a
chat with George and Thies.

-Andrei   
http://www.gravitonic.com/
* If Bill Gates had a nickel for every time Windows crashed.. Oh, 
wait.. *

--
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, visit: http://www.php.net/unsub.php


// George Schlossnagle
// Principal Consultant
// OmniTI, Inc  http://www.omniti.com
// (c) 240.460.5234   (e) [EMAIL PROTECTED]
// 1024D/1100A5A0  1370 F70A 9365 96C9 2F5E 56C2 B2B9 262F 1100 A5A0



-- PHP Development Mailing List <http://www.php.net/>
To unsubscribe, visit: http://www.php.net/unsub.php




-- 
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP-DEV] turning strlen() into an opcode

2002-11-10 Thread George Schlossnagle
Funny, it's in the message my mua said it sent (the 2nd time).  How is 
this?




It's also in pear/PECL/optimizer/zend.patch



On Sunday, November 10, 2002, at 06:11 AM, Derick Rethans wrote:


On Sat, 9 Nov 2002, George Schlossnagle wrote:


Hehe.  I should attach the patch, eh?


Yes, you should... but you still didn't do that :-)

Derick

--  

--- 

 Derick Rethans
http://derickrethans.nl/
 JDI Media Solutions
--[ if you hold a unix shell to your ear, do you hear the  
c? ]-



-- 
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP-DEV] ZEND_ADD_STRING patch

2002-11-10 Thread George Schlossnagle
For those who came to Dan & my or Derick's talk at the Int. PHP 
Conference, we both covered the bad inefficiency in the parser that 
results in strings with variables in them being tokenized on 
whitespace.  This results in a huge number of unnecessary opcodes in 
strings.

Attached (hopefully, as my new MUA seems to be fickle) is a first shot 
at a fix to the parser to  keep this from happening, so that you don't 
need an optimizer to clear up this issue.  I've tested this locally.  
It still introduces a single unnecessary opcode after variable in 
certain cases, but it works for me.

George

 
-- 
PHP Development Mailing List 
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP-DEV] ZEND_ADD_STRING patch

2002-11-10 Thread George Schlossnagle


On Sunday, November 10, 2002, at 05:06 PM, George Schlossnagle wrote:


For those who came to Dan & my or Derick's talk at the Int. PHP 
Conference, we both covered the bad inefficiency in the parser that 
results in strings with variables in them being tokenized on 
whitespace.  This results in a huge number of unnecessary opcodes in 
strings.

Attached (hopefully, as my new MUA seems to be fickle) is a first shot 
at a fix to the parser to  keep this from happening, so that you don't 
need an optimizer to clear up this issue.  I've tested this locally.  
It still introduces a single unnecessary opcode after variable in 
certain cases, but it works for me.

George


--
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, visit: http://www.php.net/unsub.php
-- 
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP-DEV] ZEND_ADD_STRING patch

2002-11-10 Thread George Schlossnagle
I got the second attachment mail ok  but I'll just inline it here:


--- Zend/zend_language_scanner.l2002-11-10 16:53:27.0 
-0500
+++ /Users/george/src/php4/Zend/zend_language_scanner.l 2002-11-10 
16:39:11.0 -0500
@@ -686,7 +686,6 @@
 HNUM   "0x"[0-9a-fA-F]+
 LABEL  [a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*
 WHITESPACE [ \n\r\t]+
-LABEL_OR_WHITESPACE [a-zA-Z0-9_\x7f-\xff \n\t\r 
#'.:;,()|^&+-/*=%!~<>?@]+
 TABS_AND_SPACES [ \t]*
 TOKENS [;:,.\[\]()|^&+-/*=%!~$<>?@]
 ENCAPSED_TOKENS [\[\]{}$]
@@ -1266,13 +1265,15 @@
 {LABEL} {
zend_copy_value(zendlval, yytext, yyleng);
zendlval->type = IS_STRING;
+fprintf(stderr, "%s:%d\n", __FILE__,__LINE__);
return T_STRING;
 }


-{LABEL_OR_WHITESPACE} {
+{LABEL} {
zend_copy_value(zendlval, yytext, yyleng);
zendlval->type = IS_STRING;
+fprintf(stderr, "%s:%d\n", __FILE__,__LINE__);
return T_STRING;
 }

@@ -1572,6 +1573,15 @@
}
 }

+
+{ESCAPED_AND_WHITESPACE} {
+   HANDLE_NEWLINES(yytext, yyleng);
+   zendlval->value.str.val = (char *) estrndup(yytext, yyleng);
+   zendlval->value.str.len = yyleng;
+   zendlval->type = IS_STRING;
+   return T_ENCAPSED_AND_WHITESPACE;
+}
+
 ([^'\\]|\\[^'\\])+ {
HANDLE_NEWLINES(yytext, yyleng);
zend_copy_value(zendlval, yytext, yyleng);


On Sunday, November 10, 2002, at 06:05 PM, Paul Nicholson wrote:

-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

It's the list, I don't think they allow attachmentsdo you have web 
space
you could upload to?

On Sunday 10 November 2002 05:16 pm, Derick Rethans wrote:
On Sun, 10 Nov 2002, George Schlossnagle wrote:

For those who came to Dan & my or Derick's talk at the Int. PHP
Conference, we both covered the bad inefficiency in the parser that
results in strings with variables in them being tokenized on
whitespace.  This results in a huge number of unnecessary opcodes in
strings.

Attached (hopefully, as my new MUA seems to be fickle) is a first 
shot
at a fix to the parser to  keep this from happening, so that you 
don't
need an optimizer to clear up this issue.  I've tested this locally.
It still introduces a single unnecessary opcode after variable in
certain cases, but it works for me.

hmm, your MUA is getting senile :) no attachment...

Derick


- --
~Paul Nicholson
Design Specialist @ WebPower Design
"The webthe way you want it!"
[EMAIL PROTECTED]
www.webpowerdesign.net

"It said uses Windows 98 or better, so I loaded Linux!"
Registered Linux User #183202 using Register Linux System # 81891
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.0.6 (GNU/Linux)
Comment: For info see http://www.gnupg.org

iD8DBQE9zuZNDyXNIUN3+UQRAlYEAJ9PE5IKScOc+7/Kk1a71jJ87o7+EgCfV9z7
u+KZNZj2lZWzXmRiZmYrq4U=
=ChWV
-END PGP SIGNATURE-



--
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP-DEV] ZEND_ADD_STRING patch

2002-11-10 Thread George Schlossnagle
that would be my debugging from my 'clean' cvs copy.  :)

You don't want that.  Sorry.  Here's a better patch:

Index: zend_language_scanner.l
===
RCS file: /repository/Zend/zend_language_scanner.l,v
retrieving revision 1.51
diff -u -3 -r1.51 zend_language_scanner.l
--- zend_language_scanner.l 2 Nov 2002 16:32:26 -   1.51
+++ zend_language_scanner.l 10 Nov 2002 23:30:28 -
@@ -686,6 +686,7 @@
 HNUM   "0x"[0-9a-fA-F]+
 LABEL  [a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*
 WHITESPACE [ \n\r\t]+
+LABEL_OR_WHITESPACE [a-zA-Z0-9_\x7f-\xff \n\t\r 
#'.:;,()|^&+-/*=%!~<>?@]+
 TABS_AND_SPACES [ \t]*
 TOKENS [;:,.\[\]()|^&+-/*=%!~$<>?@]
 ENCAPSED_TOKENS [\[\]{}$]
@@ -1269,7 +1270,7 @@
 }


-{LABEL} {
+{LABEL_OR_WHITESPACE} {
zend_copy_value(zendlval, yytext, yyleng);
zendlval->type = IS_STRING;
return T_STRING;
@@ -1569,15 +1570,6 @@
zendlval->type = IS_STRING;
return T_STRING;
}
-}
-
-
-{ESCAPED_AND_WHITESPACE} {
-   HANDLE_NEWLINES(yytext, yyleng);
-   zendlval->value.str.val = (char *) estrndup(yytext, yyleng);
-   zendlval->value.str.len = yyleng;
-   zendlval->type = IS_STRING;
-   return T_ENCAPSED_AND_WHITESPACE;
 }

 ([^'\\]|\\[^'\\])+ {





On Sunday, November 10, 2002, at 06:25 PM, Moriyoshi Koizumi wrote:

--snip

+fprintf(stderr, "%s:%d\n", __FILE__,__LINE__);


What's this fprintf()? This seems to be put just for debugging purpose.

Moriyosh




 return T_STRING;
  }


-{LABEL_OR_WHITESPACE} {
+{LABEL} {
 zend_copy_value(zendlval, yytext, yyleng);
 zendlval->type = IS_STRING;
+fprintf(stderr, "%s:%d\n", __FILE__,__LINE__);
 return T_STRING;
  }

@@ -1572,6 +1573,15 @@
 }
  }

+
+{ESCAPED_AND_WHITESPACE} {
+   HANDLE_NEWLINES(yytext, yyleng);
+   zendlval->value.str.val = (char *) estrndup(yytext, yyleng);
+   zendlval->value.str.len = yyleng;
+   zendlval->type = IS_STRING;
+   return T_ENCAPSED_AND_WHITESPACE;
+}
+
  ([^'\\]|\\[^'\\])+ {
 HANDLE_NEWLINES(yytext, yyleng);
 zend_copy_value(zendlval, yytext, yyleng);


On Sunday, November 10, 2002, at 06:05 PM, Paul Nicholson wrote:


-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

It's the list, I don't think they allow attachmentsdo you have 
web
space
you could upload to?

On Sunday 10 November 2002 05:16 pm, Derick Rethans wrote:
On Sun, 10 Nov 2002, George Schlossnagle wrote:

For those who came to Dan & my or Derick's talk at the Int. PHP
Conference, we both covered the bad inefficiency in the parser that
results in strings with variables in them being tokenized on
whitespace.  This results in a huge number of unnecessary opcodes 
in
strings.

Attached (hopefully, as my new MUA seems to be fickle) is a first
shot
at a fix to the parser to  keep this from happening, so that you
don't
need an optimizer to clear up this issue.  I've tested this 
locally.
It still introduces a single unnecessary opcode after variable in
certain cases, but it works for me.

hmm, your MUA is getting senile :) no attachment...

Derick


- --
~Paul Nicholson
Design Specialist @ WebPower Design
"The webthe way you want it!"
[EMAIL PROTECTED]
www.webpowerdesign.net

"It said uses Windows 98 or better, so I loaded Linux!"
Registered Linux User #183202 using Register Linux System # 81891
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.0.6 (GNU/Linux)
Comment: For info see http://www.gnupg.org

iD8DBQE9zuZNDyXNIUN3+UQRAlYEAJ9PE5IKScOc+7/Kk1a71jJ87o7+EgCfV9z7
u+KZNZj2lZWzXmRiZmYrq4U=
=ChWV
-END PGP SIGNATURE-



--
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, visit: http://www.php.net/unsub.php




--
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, visit: http://www.php.net/unsub.php




--
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP-DEV] Re: apache_hooks

2002-11-10 Thread George Schlossnagle
While most of the code in main/ is changed minimally, the changes to 
the SAPI/apache stuff are pretty extensive.  It may make sense to ifdef 
the changes in main and create a new SAPI module for this.  I bend to 
the majority though.  :)


On Sunday, November 3, 2002, at 03:49 AM, Rasmus Lerdorf wrote:

Well, since 99% of the code is the same, I'd be worried about people
remembering to merge fixes across.  At least if it is ifdef'ed people 
see
the code.  But yes, I agree, that's not pretty either.

-R

On Sun, 3 Nov 2002, George Schlossnagle wrote:

Either way works for me.  Psychologically, I think it may get higher
exposure if it is #ifdef'd, but I have style reservations about doing
that.  How has this sort of thing been done in the past?  Is it
undesirable to fork the apache sapi into a new 'apache_hooks' sapi?
That may be easiest.

George

On Saturday, November 2, 2002, at 05:58 PM, Rasmus Lerdorf wrote:


What do you think would be the best way to make the apache_hooks code
more
accessible to people?  A tarball with the relevant files that 
overwrites
the standard files, or perhaps it is time to #ifdef it into the main
branch?

-Rasmus


// George Schlossnagle
// Principal Consultant
// OmniTI, Inc  http://www.omniti.com
// (c) 240.460.5234   (e) [EMAIL PROTECTED]
// 1024D/1100A5A0  1370 F70A 9365 96C9 2F5E 56C2 B2B9 262F 1100 A5A0






--
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP-DEV] ZEND_ADD_STRING patch

2002-11-10 Thread George Schlossnagle
Unless I misunderstand the way this works, it's not a problem that it 
returns a T_STRING, only possibly that it does so inside a BACKQUOTES.  
Function names and constants aren't available as barewords in 
DOUBLE_QUOTES or HEREDOCs, right?


On Monday, November 11, 2002, at 01:12 AM, Andi Gutmans wrote:

Hi,

A patch which improves on this would be welcome.
However, this patch at first glance is bogus. You are returning 
T_STRING with possible spaces and other non A-Za-z_ chars. This token 
is also used as tokens such as constants and function names .

Andi

At 06:31 PM 11/10/2002 -0500, George Schlossnagle wrote:
that would be my debugging from my 'clean' cvs copy.  :)

You don't want that.  Sorry.  Here's a better patch:

Index: zend_language_scanner.l
===
RCS file: /repository/Zend/zend_language_scanner.l,v
retrieving revision 1.51
diff -u -3 -r1.51 zend_language_scanner.l
--- zend_language_scanner.l 2 Nov 2002 16:32:26 -   1.51
+++ zend_language_scanner.l 10 Nov 2002 23:30:28 -
@@ -686,6 +686,7 @@
 HNUM   "0x"[0-9a-fA-F]+
 LABEL  [a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*
 WHITESPACE [ \n\r\t]+
+LABEL_OR_WHITESPACE [a-zA-Z0-9_\x7f-\xff \n\t\r 
#'.:;,()|^&+-/*=%!~<>?@]+
 TABS_AND_SPACES [ \t]*
 TOKENS [;:,.\[\]()|^&+-/*=%!~$<>?@]
 ENCAPSED_TOKENS [\[\]{}$]
@@ -1269,7 +1270,7 @@
 }


-{LABEL} {
+{LABEL_OR_WHITESPACE} {
zend_copy_value(zendlval, yytext, yyleng);
zendlval->type = IS_STRING;
return T_STRING;
@@ -1569,15 +1570,6 @@
zendlval->type = IS_STRING;
return T_STRING;
}
-}
-
-
-{ESCAPED_AND_WHITESPACE} {
-   HANDLE_NEWLINES(yytext, yyleng);
-   zendlval->value.str.val = (char *) estrndup(yytext, yyleng);
-   zendlval->value.str.len = yyleng;
-   zendlval->type = IS_STRING;
-   return T_ENCAPSED_AND_WHITESPACE;
 }

 ([^'\\]|\\[^'\\])+ {





On Sunday, November 10, 2002, at 06:25 PM, Moriyoshi Koizumi wrote:

--snip

+fprintf(stderr, "%s:%d\n", __FILE__,__LINE__);


What's this fprintf()? This seems to be put just for debugging 
purpose.

Moriyosh



 return T_STRING;
  }


-{LABEL_OR_WHITESPACE} {
+{LABEL} {
 zend_copy_value(zendlval, yytext, yyleng);
 zendlval->type = IS_STRING;
+fprintf(stderr, "%s:%d\n", __FILE__,__LINE__);
 return T_STRING;
  }

@@ -1572,6 +1573,15 @@
 }
  }

+
+{ESCAPED_AND_WHITESPACE} 
{
+   HANDLE_NEWLINES(yytext, yyleng);
+   zendlval->value.str.val = (char *) estrndup(yytext, yyleng);
+   zendlval->value.str.len = yyleng;
+   zendlval->type = IS_STRING;
+   return T_ENCAPSED_AND_WHITESPACE;
+}
+
  ([^'\\]|\\[^'\\])+ {
 HANDLE_NEWLINES(yytext, yyleng);
 zend_copy_value(zendlval, yytext, yyleng);


On Sunday, November 10, 2002, at 06:05 PM, Paul Nicholson wrote:

-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

It's the list, I don't think they allow attachments....do you have 
web
space
you could upload to?

On Sunday 10 November 2002 05:16 pm, Derick Rethans wrote:
On Sun, 10 Nov 2002, George Schlossnagle wrote:

For those who came to Dan & my or Derick's talk at the Int. PHP
Conference, we both covered the bad inefficiency in the parser 
that
results in strings with variables in them being tokenized on
whitespace.  This results in a huge number of unnecessary 
opcodes in
strings.

Attached (hopefully, as my new MUA seems to be fickle) is a first
shot
at a fix to the parser to  keep this from happening, so that you
don't
need an optimizer to clear up this issue.  I've tested this 
locally.
It still introduces a single unnecessary opcode after variable in
certain cases, but it works for me.

hmm, your MUA is getting senile :) no attachment...

Derick


- --
~Paul Nicholson
Design Specialist @ WebPower Design
"The webthe way you want it!"
[EMAIL PROTECTED]
www.webpowerdesign.net

"It said uses Windows 98 or better, so I loaded Linux!"
Registered Linux User #183202 using Register Linux System # 81891
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.0.6 (GNU/Linux)
Comment: For info see http://www.gnupg.org

iD8DBQE9zuZNDyXNIUN3+UQRAlYEAJ9PE5IKScOc+7/Kk1a71jJ87o7+EgCfV9z7
u+KZNZj2lZWzXmRiZmYrq4U=
=ChWV
-END PGP SIGNATURE-



--
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, visit: http://www.php.net/unsub.php



--
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, visit: http://www.php.net/unsub.php



--
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, visit: http://www.php.net/unsub.php



--
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, visit: http://www.php.net/unsub.php




--
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP-DEV] ZEND_ADD_STRING patch

2002-11-11 Thread George Schlossnagle
The patch I submitted included BACKQUOTES in the token matching as  
well.  I'm not convinced that is bad, but I will try to thoroughly test  
it tomorrow, and if it's broken, I'll just case it for " and heredocs.

George


On Monday, November 11, 2002, at 01:56 AM, Andi Gutmans wrote:

OH I missed that. I'll check it out this evening as I have to go now.

Andi

At 01:48 AM 11/11/2002 -0500, George Schlossnagle wrote:

Unless I misunderstand the way this works, it's not a problem that it  
returns a T_STRING, only possibly that it does so inside a >> BACKQUOTES.
Function names and constants aren't available as barewords in  
DOUBLE_QUOTES or HEREDOCs, right?


On Monday, November 11, 2002, at 01:12 AM, Andi Gutmans wrote:

Hi,

A patch which improves on this would be welcome.
However, this patch at first glance is bogus. You are returning  
T_STRING with possible spaces and other non A-Za-z_ chars. This  
token is also used as tokens such as constants and function names .

Andi

At 06:31 PM 11/10/2002 -0500, George Schlossnagle wrote:
that would be my debugging from my 'clean' cvs copy.  :)

You don't want that.  Sorry.  Here's a better patch:

Index: zend_language_scanner.l
===
RCS file: /repository/Zend/zend_language_scanner.l,v
retrieving revision 1.51
diff -u -3 -r1.51 zend_language_scanner.l
--- zend_language_scanner.l 2 Nov 2002 16:32:26 -   1.51
+++ zend_language_scanner.l 10 Nov 2002 23:30:28 -
@@ -686,6 +686,7 @@
 HNUM   "0x"[0-9a-fA-F]+
 LABEL  [a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*
 WHITESPACE [ \n\r\t]+
+LABEL_OR_WHITESPACE [a-zA-Z0-9_\x7f-\xff \n\t\r  
#'.:;,()|^&+-/*=%!~<>?@]+
 TABS_AND_SPACES [ \t]*
 TOKENS [;:,.\[\]()|^&+-/*=%!~$<>?@]
 ENCAPSED_TOKENS [\[\]{}$]
@@ -1269,7 +1270,7 @@
 }


-{LABEL} {
+{LABEL_OR_WHITESPACE} {
zend_copy_value(zendlval, yytext, yyleng);
zendlval->type = IS_STRING;
return T_STRING;
@@ -1569,15 +1570,6 @@
zendlval->type = IS_STRING;
return T_STRING;
}
-}
-
-
-{ESCAPED_AND_WHITESPACE}  
{
-   HANDLE_NEWLINES(yytext, yyleng);
-   zendlval->value.str.val = (char *) estrndup(yytext, yyleng);
-   zendlval->value.str.len = yyleng;
-   zendlval->type = IS_STRING;
-   return T_ENCAPSED_AND_WHITESPACE;
 }

 ([^'\\]|\\[^'\\])+ {





On Sunday, November 10, 2002, at 06:25 PM, Moriyoshi Koizumi wrote:

--snip

+fprintf(stderr, "%s:%d\n", __FILE__,__LINE__);


What's this fprintf()? This seems to be put just for debugging  
purpose.

Moriyosh



 return T_STRING;
  }


-{LABEL_OR_WHITESPACE} {
+{LABEL} {
 zend_copy_value(zendlval, yytext, yyleng);
 zendlval->type = IS_STRING;
+fprintf(stderr, "%s:%d\n", __FILE__,__LINE__);
 return T_STRING;
  }

@@ -1572,6 +1573,15 @@
 }
  }

+
+{ESCAPED_AND_WHITESPACE 
} {
+   HANDLE_NEWLINES(yytext, yyleng);
+   zendlval->value.str.val = (char *) estrndup(yytext,  
yyleng);
+   zendlval->value.str.len = yyleng;
+   zendlval->type = IS_STRING;
+   return T_ENCAPSED_AND_WHITESPACE;
+}
+
  ([^'\\]|\\[^'\\])+ {
 HANDLE_NEWLINES(yytext, yyleng);
 zend_copy_value(zendlval, yytext, yyleng);


On Sunday, November 10, 2002, at 06:05 PM, Paul Nicholson wrote:

-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

It's the list, I don't think they allow attachmentsdo you  
have web
space
you could upload to?

On Sunday 10 November 2002 05:16 pm, Derick Rethans wrote:
On Sun, 10 Nov 2002, George Schlossnagle wrote:

For those who came to Dan & my or Derick's talk at the Int. PHP
Conference, we both covered the bad inefficiency in the parser  
that
results in strings with variables in them being tokenized on
whitespace.  This results in a huge number of unnecessary  
opcodes in
strings.

Attached (hopefully, as my new MUA seems to be fickle) is a  
first
shot
at a fix to the parser to  keep this from happening, so that  
you
don't
need an optimizer to clear up this issue.  I've tested this  
locally.
It still introduces a single unnecessary opcode after variable  
in
certain cases, but it works for me.

hmm, your MUA is getting senile :) no attachment...

Derick


- --
~Paul Nicholson
Design Specialist @ WebPower Design
"The webthe way you want it!"
[EMAIL PROTECTED]
www.webpowerdesign.net

"It said uses Windows 98 or better, so I loaded Linux!"
Registered Linux User #183202 using Register Linux System # 81891
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.0.6 (GNU/Linux)
Comment: For info see http://www.gnupg.org

iD8DBQE9zuZNDyXNIUN3+UQRAlYEAJ9PE5IKScOc+7/Kk1a71jJ87o7+EgCfV9z7
u+KZNZj2lZWzXmRiZmYrq4U=
=ChWV
-END PGP SIGNATURE-



--
PHP Development Mailing List <ht

Re: [PHP-DEV] Re: apache_hooks

2002-11-11 Thread George Schlossnagle
apache_hooks is a proper superset of mod_php, so you would only need to 
load apache_hooks.



On Monday, November 11, 2002, at 03:52 AM, Edin Kadribasic wrote:

Hrm..  That's not a bad idea.  An ApacheHooks SAPI module sounds

like the

right approach to me.


Would it be possible to load them both (ApacheHooks and mod_php) at
the same time?

Edin


--
PHP Development Mailing List 
To unsubscribe, visit: http://www.php.net/unsub.php




--
PHP Development Mailing List 
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP-DEV] ZEND_ADD_STRING patch

2002-11-11 Thread George Schlossnagle
Hi,

You're right.  This patch should address that concern:

diff -u -3 -r1.51 zend_language_scanner.l
--- zend_language_scanner.l 2 Nov 2002 16:32:26 -   1.51
+++ zend_language_scanner.l 11 Nov 2002 22:17:09 -
@@ -32,6 +32,7 @@
 %}

 %x ST_IN_SCRIPTING
+%x ST_EXPECTING_OBJECT
 %x ST_DOUBLE_QUOTES
 %x ST_SINGLE_QUOTE
 %x ST_BACKQUOTE
@@ -686,6 +687,7 @@
 HNUM   "0x"[0-9a-fA-F]+
 LABEL  [a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*
 WHITESPACE [ \n\r\t]+
+LABEL_OR_WHITESPACE [a-zA-Z0-9_\x7f-\xff \n\t\r  
#'.:;,()|^&+-/*=%!~<>?@]+
 TABS_AND_SPACES [ \t]*
 TOKENS [;:,.\[\]()|^&+-/*=%!~$<>?@]
 ENCAPSED_TOKENS [\[\]{}$]
@@ -817,7 +819,13 @@
return T_EXTENDS;
 }

-"->" {
+"$"{LABEL}"- 
>"{LABEL} {
+yy_push_state(ST_EXPECTING_OBJECT TSRMLS_CC);
+yyless(0);
+}
+
+"->" {
+fprintf(stderr, "matched T_OBJECT_OPERATOR\n");
yy_push_state(ST_LOOKING_FOR_PROPERTY TSRMLS_CC);
return T_OBJECT_OPERATOR;
 }
@@ -830,7 +838,7 @@
return T_STRING;
 }

-{ANY_CHAR} {
+{ANY_CHAR} {
yyless(0);
yy_pop_state(TSRMLS_C);
 }
@@ -1255,7 +1263,7 @@
return T_INLINE_HTML;
 }

-"$"{LABEL} {
+"$"{LABEL} {
zend_copy_value(zendlval, (yytext+1), (yyleng-1));
zendlval->type = IS_STRING;
return T_VARIABLE;
@@ -1269,7 +1277,7 @@
 }


-{LABEL} {
+{LABEL_OR_WHITESPACE} {
zend_copy_value(zendlval, yytext, yyleng);
zendlval->type = IS_STRING;
return T_STRING;
@@ -1569,15 +1577,6 @@
zendlval->type = IS_STRING;
return T_STRING;
}
-}
-
-
-{ESCAPED_AND_WHITESPACE} {
-   HANDLE_NEWLINES(yytext, yyleng);
-   zendlval->value.str.val = (char *) estrndup(yytext, yyleng);
-   zendlval->value.str.len = yyleng;
-   zendlval->type = IS_STRING;
-   return T_ENCAPSED_AND_WHITESPACE;
 }

 ([^'\\]|\\[^'\\])+ {



On Monday, November 11, 2002, at 02:44 PM, Andi Gutmans wrote:

Hi,

I still think the patch isn't good. encaps_list which is the main  
parser rule can parse:
 T_VARIABLE T_OBJECT_OPERATOR T_STRING
Your version of T_STRING would break this.
Again I might be missing something but my hunch is that it would break.
Andi

At 03:06 AM 11/11/2002 -0500, George Schlossnagle wrote:
The patch I submitted included BACKQUOTES in the token matching as
well.  I'm not convinced that is bad, but I will try to thoroughly  
test
it tomorrow, and if it's broken, I'll just case it for " and heredocs.

George


On Monday, November 11, 2002, at 01:56 AM, Andi Gutmans wrote:

OH I missed that. I'll check it out this evening as I have to go now.

Andi

At 01:48 AM 11/11/2002 -0500, George Schlossnagle wrote:

Unless I misunderstand the way this works, it's not a problem that  
it
returns a T_STRING, only possibly that it does so inside a >>  
BACKQUOTES.
Function names and constants aren't available as barewords in
DOUBLE_QUOTES or HEREDOCs, right?


On Monday, November 11, 2002, at 01:12 AM, Andi Gutmans wrote:

Hi,

A patch which improves on this would be welcome.
However, this patch at first glance is bogus. You are returning
T_STRING with possible spaces and other non A-Za-z_ chars. This
token is also used as tokens such as constants and function names .

Andi

At 06:31 PM 11/10/2002 -0500, George Schlossnagle wrote:

that would be my debugging from my 'clean' cvs copy.  :)

You don't want that.  Sorry.  Here's a better patch:

Index: zend_language_scanner.l
== 
=
RCS file: /repository/Zend/zend_language_scanner.l,v
retrieving revision 1.51
diff -u -3 -r1.51 zend_language_scanner.l
--- zend_language_scanner.l 2 Nov 2002 16:32:26 -
1.51
+++ zend_language_scanner.l 10 Nov 2002 23:30:28 -
@@ -686,6 +686,7 @@
 HNUM   "0x"[0-9a-fA-F]+
 LABEL  [a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*
 WHITESPACE [ \n\r\t]+
+LABEL_OR_WHITESPACE [a-zA-Z0-9_\x7f-\xff \n\t\r
#'.:;,()|^&+-/*=%!~<>?@]+
 TABS_AND_SPACES [ \t]*
 TOKENS [;:,.\[\]()|^&+-/*=%!~$<>?@]
 ENCAPSED_TOKENS [\[\]{}$]
@@ -1269,7 +1270,7 @@
 }


-{LABEL} {
+{LABEL_OR_WHITESPACE} {
zend_copy_value(zendlval, yytext, yyleng);
zendlval->type = IS_STRING;
return T_STRING;
@@ -1569,15 +1570,6 @@
zendlval->type = IS_STRING;
return T_STRING;
}
-}
-
-
- 
{ESCAPED_AND_WHITESPACE}
{
-   HANDLE_NEWLINES(yytext, yyleng);
-   zendlval->value.str.val = (char *) estrndup(yytext,  
yyleng);
-   zendlval->value.str.len = yyleng;
-   zendlval->type = IS_STRING;
-   return T_ENCAPSED_AND_WHITESPACE;
 }

 ([^'\\]|\\[^'\\])+ {





On Sunday, November 10, 2002, at 06:25 PM, Moriyoshi Koizumi  
wrote:

--snip

+fpr

Re: [PHP-DEV] Re: apache_hooks

2002-11-12 Thread George Schlossnagle
So I will take this course of action after 4.3.0 is branched.  Any 
objections?

George

On Sunday, November 10, 2002, at 09:40 PM, Rasmus Lerdorf wrote:

Hrm..  That's not a bad idea.  An ApacheHooks SAPI module sounds like 
the
right approach to me.

-R

On Sun, 10 Nov 2002, George Schlossnagle wrote:

While most of the code in main/ is changed minimally, the changes to
the SAPI/apache stuff are pretty extensive.  It may make sense to 
ifdef
the changes in main and create a new SAPI module for this.  I bend to
the majority though.  :)


On Sunday, November 3, 2002, at 03:49 AM, Rasmus Lerdorf wrote:

Well, since 99% of the code is the same, I'd be worried about people
remembering to merge fixes across.  At least if it is ifdef'ed people
see
the code.  But yes, I agree, that's not pretty either.

-R

On Sun, 3 Nov 2002, George Schlossnagle wrote:


Either way works for me.  Psychologically, I think it may get higher
exposure if it is #ifdef'd, but I have style reservations about 
doing
that.  How has this sort of thing been done in the past?  Is it
undesirable to fork the apache sapi into a new 'apache_hooks' sapi?
That may be easiest.

George

On Saturday, November 2, 2002, at 05:58 PM, Rasmus Lerdorf wrote:

What do you think would be the best way to make the apache_hooks 
code
more
accessible to people?  A tarball with the relevant files that
overwrites
the standard files, or perhaps it is time to #ifdef it into the 
main
branch?

-Rasmus


// George Schlossnagle
// Principal Consultant
// OmniTI, Inc  http://www.omniti.com
// (c) 240.460.5234   (e) [EMAIL PROTECTED]
// 1024D/1100A5A0  1370 F70A 9365 96C9 2F5E 56C2 B2B9 262F 1100 A5A0






--
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, visit: http://www.php.net/unsub.php






--
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP-DEV] [RFC] adding sapi_module_struct.pretty_name to $_SERVER

2002-11-12 Thread George Schlossnagle
How do people feel about adding the pretty name as $_SERVER['SAPI']?


--
PHP Development Mailing List 
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP-DEV] ZEND_ADD_STRING patch

2002-11-12 Thread George Schlossnagle
Hi Andi,

The last patch I submitted was broken as well.  Following that, I had 
the bright idea to run the prospective changes through the unit-tester 
to ensure correct performance.  Here's a patch which achieves that.  It 
does not work for heredocs (i.e. they are tokenized as before, but 
behave correctly from a language perspective), but otherwise optimizes 
correctly.

Here you go:

diff -u -3 -r1.53 zend_language_scanner.l
--- Zend/zend_language_scanner.l8 Nov 2002 13:40:54 -1.53
+++ Zend/zend_language_scanner.l12 Nov 2002 22:11:31 -
@@ -37,6 +37,7 @@
%x ST_BACKQUOTE
%x ST_HEREDOC
%x ST_LOOKING_FOR_PROPERTY
+%x ST_EXPECTING_OBJECT
%x ST_LOOKING_FOR_VARNAME
%x ST_COMMENT
%x ST_ONE_LINE_COMMENT
@@ -692,6 +693,7 @@
HNUM"0x"[0-9a-fA-F]+
LABEL[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*
WHITESPACE [ \n\r\t]+
+LABEL_OR_WHITESPACE [a-zA-Z0-9_\x7f-\xff \t\n\r #'.:;,()|^&+-/*=%!~<>?@]+
TABS_AND_SPACES [ \t]*
TOKENS [;:,.\[\]()|^&+-/*=%!~$<>?@]
ENCAPSED_TOKENS [\[\]{}$]
@@ -823,13 +825,22 @@
return T_EXTENDS;
}

-"->" {
+"$"{LABEL}"->"{LABEL} {
+yy_push_state(ST_EXPECTING_OBJECT TSRMLS_CC);
+yyless(0);
+}
+
+
+"->" {
yy_push_state(ST_LOOKING_FOR_PROPERTY TSRMLS_CC);
return T_OBJECT_OPERATOR;
}

{LABEL} {
yy_pop_state(TSRMLS_C);
+if(yy_top_state(TSRMLS_C) == ST_EXPECTING_OBJECT) {
+yy_pop_state(TSRMLS_C);
+}
 zend_copy_value(zendlval, yytext, yyleng);
zendlval->value.str.len = yyleng;
zendlval->type = IS_STRING;
@@ -1265,7 +1276,7 @@
return T_INLINE_HTML;
}

-"$"{LABEL} {
+"$"{LABEL} 
{
 zend_copy_value(zendlval, (yytext+1), (yyleng-1));
zendlval->type = IS_STRING;
return T_VARIABLE;
@@ -1278,13 +1289,26 @@
return T_STRING;
}

-
-{LABEL} {
+{LABEL_OR_WHITESPACE} {
+HANDLE_NEWLINES(yytext, yyleng);
 zend_copy_value(zendlval, yytext, yyleng);
zendlval->type = IS_STRING;
return T_STRING;
}

+{LABEL} {
+zend_copy_value(zendlval, yytext, yyleng);
+zendlval->type = IS_STRING;
+return T_STRING;
+}
+
+{ESCAPED_AND_WHITESPACE} {
+HANDLE_NEWLINES(yytext, yyleng);
+zendlval->value.str.val = (char *) estrndup(yytext, yyleng);
+zendlval->value.str.len = yyleng;
+zendlval->type = IS_STRING;
+return T_ENCAPSED_AND_WHITESPACE;
+}

{WHITESPACE} {
zendlval->value.str.val = yytext; /* no copying - intentional */
@@ -1581,14 +1605,6 @@
}
}

-
-{ESCAPED_AND_WHITESPACE} {
-HANDLE_NEWLINES(yytext, yyleng);
-zendlval->value.str.val = (char *) estrndup(yytext, yyleng);
-zendlval->value.str.len = yyleng;
-zendlval->type = IS_STRING;
-return T_ENCAPSED_AND_WHITESPACE;
-}

([^'\\]|\\[^'\\])+ {
HANDLE_NEWLINES(yytext, yyleng);



--
PHP Development Mailing List 
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DEV] ZEND_ADD_STRING patch

2002-11-15 Thread George Schlossnagle
George Schlossnagle wrote:


I'm a tool.  I sent the wrong patch to the list.  Thanks to Andrei for 
pointing it out.  Here is the _right_ patch (finally).


diff -u -3 -r1.53 zend_language_scanner.l
--- zend_language_scanner.l8 Nov 2002 13:40:54 -1.53
+++ zend_language_scanner.l15 Nov 2002 20:20:33 -
@@ -37,6 +37,7 @@
%x ST_BACKQUOTE
%x ST_HEREDOC
%x ST_LOOKING_FOR_PROPERTY
+%x ST_EXPECTING_OBJECT
%x ST_LOOKING_FOR_VARNAME
%x ST_COMMENT
%x ST_ONE_LINE_COMMENT
@@ -692,6 +693,7 @@
HNUM"0x"[0-9a-fA-F]+
LABEL[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*
WHITESPACE [ \n\r\t]+
+LABEL_OR_WHITESPACE [a-zA-Z0-9_\x7f-\xff \t\n\r #'.:;,()|^&+-/*=%!~<>?@]+
TABS_AND_SPACES [ \t]*
TOKENS [;:,.\[\]()|^&+-/*=%!~$<>?@]
ENCAPSED_TOKENS [\[\]{}$]
@@ -823,13 +825,25 @@
return T_EXTENDS;
}

-"->" {
+"$"{LABEL}"->"{LABEL} {
+yy_push_state(ST_EXPECTING_OBJECT TSRMLS_CC);
+yyless(0);
+}
+
+
+"->" {
yy_push_state(ST_LOOKING_FOR_PROPERTY TSRMLS_CC);
return T_OBJECT_OPERATOR;
}

{LABEL} {
-yy_pop_state(TSRMLS_C);
+if(yy_top_state(TSRMLS_C) == ST_EXPECTING_OBJECT) {
+yy_pop_state(TSRMLS_C);
+yy_pop_state(TSRMLS_C);
+}
+else {
+yy_pop_state(TSRMLS_C);
+}
 zend_copy_value(zendlval, yytext, yyleng);
zendlval->value.str.len = yyleng;
zendlval->type = IS_STRING;
@@ -1265,7 +1279,7 @@
return T_INLINE_HTML;
}

-"$"{LABEL} {
+"$"{LABEL} 
{
 zend_copy_value(zendlval, (yytext+1), (yyleng-1));
zendlval->type = IS_STRING;
return T_VARIABLE;
@@ -1278,13 +1292,26 @@
return T_STRING;
}

-
-{LABEL} {
+{LABEL_OR_WHITESPACE} {
+HANDLE_NEWLINES(yytext, yyleng);
 zend_copy_value(zendlval, yytext, yyleng);
zendlval->type = IS_STRING;
return T_STRING;
}

+{LABEL} {
+zend_copy_value(zendlval, yytext, yyleng);
+zendlval->type = IS_STRING;
+return T_STRING;
+}
+
+{ESCAPED_AND_WHITESPACE} {
+HANDLE_NEWLINES(yytext, yyleng);
+zendlval->value.str.val = (char *) estrndup(yytext, yyleng);
+zendlval->value.str.len = yyleng;
+zendlval->type = IS_STRING;
+return T_ENCAPSED_AND_WHITESPACE;
+}

{WHITESPACE} {
zendlval->value.str.val = yytext; /* no copying - intentional */
@@ -1581,14 +1608,6 @@
}
}

-
-{ESCAPED_AND_WHITESPACE} {
-HANDLE_NEWLINES(yytext, yyleng);
-zendlval->value.str.val = (char *) estrndup(yytext, yyleng);
-zendlval->value.str.len = yyleng;
-zendlval->type = IS_STRING;
-return T_ENCAPSED_AND_WHITESPACE;
-}

([^'\\]|\\[^'\\])+ {
HANDLE_NEWLINES(yytext, yyleng);



--
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DEV] ZEND_ADD_STRING patch

2002-11-15 Thread George Schlossnagle
Andi Gutmans wrote:



Try it out and let me know how the results are. Also *please* send 
diffs also as attachments so that when people apply them we won't get 
bad whitespace in our sources. 


php-dev seems to eat my attachments




--
PHP Development Mailing List 
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP-DEV] ZEND_ADD_STRING patch

2002-11-15 Thread George Schlossnagle
Much sexier indeed.  There are some flaws with it:

o  Tokenizes heredocs on whitespace
o  Doesn't count lines correctly for debug (since strings now have 
newlines in them)

Here's a revised patch to yours that fixes those (heredocs are tokenized 
on newlines - I think that is best case)


Andi Gutmans wrote:

I propose something like the following: (not tested)
It's definitely a sexier patch :)

Andi

RCS file: /repository/ZendEngine2/zend_language_scanner.l,v
retrieving revision 1.62
diff -u -u -r1.62 zend_language_scanner.l
--- zend_language_scanner.l 5 Nov 2002 22:01:35 -   1.62
+++ zend_language_scanner.l 15 Nov 2002 23:22:34 -
@@ -474,6 +474,7 @@
 EXPONENT_DNUM  (({LNUM}|{DNUM})[eE][+-]?{LNUM})
 HNUM   "0x"[0-9a-fA-F]+
 LABEL  [a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*
+ENCAPSED_STRING ([a-zA-Z0-9_\x7f-\xff \t\n\r 
#'.:;,()|^&+/*=%!~<>?@]|"-"[^>])+
 WHITESPACE [ \n\r\t]+
 TABS_AND_SPACES [ \t]*
 TOKENS [;:,.\[\]()|^&+-/*=%!~$<>?@]
@@ -1076,6 +1077,12 @@
return T_VARIABLE;
 }

+{ENCAPSED_STRING} {
+   zendlval->value.str.val = (char *)estrndup(yytext, yyleng);
+   zendlval->value.str.len = yyleng;
+   zendlval->type = IS_STRING;
+   return T_STRING;
+}

 {LABEL} {
zendlval->value.str.val = (char *)estrndup(yytext, yyleng);
@@ -1085,7 +1092,7 @@
 }


-{LABEL} {
+{LABEL} {
zendlval->value.str.val = (char *)estrndup(yytext, yyleng);
zendlval->value.str.len = yyleng;
zendlval->type = IS_STRING;
@@ -1374,7 +1381,7 @@
 }


-{ESCAPED_AND_WHITESPACE} {
+{ESCAPED_AND_WHITESPACE} {
HANDLE_NEWLINES(yytext, yyleng);
zendlval->value.str.val = (char *) estrndup(yytext, yyleng);
zendlval->value.str.len = yyleng;



Andi





Index: Zend/zend_language_scanner.l
===
RCS file: /repository/Zend/zend_language_scanner.l,v
retrieving revision 1.54
diff -u -3 -r1.54 zend_language_scanner.l
--- Zend/zend_language_scanner.l13 Nov 2002 03:28:23 -  1.54
+++ Zend/zend_language_scanner.l15 Nov 2002 23:47:29 -
@@ -95,7 +95,7 @@
   
 \
while (p@ -707,6 +707,8 @@
 EXPONENT_DNUM  (({LNUM}|{DNUM})[eE][+-]?{LNUM})
 HNUM   "0x"[0-9a-fA-F]+
 LABEL  [a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*
+ENCAPSED_STRING ([a-zA-Z0-9_\x7f-\xff \t #'.:;,()|^&+/*=%!~<>?@]|"-"[^>])+ 
+ENCAPSED_STRING_WITH_NEWLINE ([a-zA-Z0-9_\x7f-\xff \t\n\r 
+#'.:;,()|^&+/*=%!~<>?@]|"-"[^>])+ 
 WHITESPACE [ \n\r\t]+
 TABS_AND_SPACES [ \t]*
 TOKENS [;:,.\[\]()|^&+-/*=%!~$<>?@]
@@ -1287,6 +1289,13 @@
return T_VARIABLE;
 }
 
+{ENCAPSED_STRING_WITH_NEWLINE} {
+   HANDLE_NEWLINES(yytext, yyleng);
+   zendlval->value.str.val = (char *)estrndup(yytext, yyleng);
+   zendlval->value.str.len = yyleng;
+   zendlval->type = IS_STRING;
+   return T_STRING;
+}
 
 {LABEL} {
zend_copy_value(zendlval, yytext, yyleng);
@@ -1295,7 +1304,7 @@
 }
 
 
-{LABEL} {
+{ENCAPSED_STRING} {
zend_copy_value(zendlval, yytext, yyleng);
zendlval->type = IS_STRING;
return T_STRING;
@@ -1598,7 +1607,7 @@
 }
 
 
-{ESCAPED_AND_WHITESPACE} {
+{ESCAPED_AND_WHITESPACE} {
HANDLE_NEWLINES(yytext, yyleng);
zendlval->value.str.val = (char *) estrndup(yytext, yyleng);
zendlval->value.str.len = yyleng;


-- 
PHP Development Mailing List 
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP-DEV] ZEND_ADD_STRING patch

2002-11-16 Thread George Schlossnagle
Hi,

There is a problem with the patch committed.  It incorrectly tokenizes 
things like

$foo = "%-{$bar}"

(this breaks the PEAR installer, amongst other things)

I've attached a fix for it.

Also, it looks like you didn't accept the part of the fix that allows 
for enhanced handling of heredocs.  Is there a reason why?  I'm 
sticking that in this patch again, in case you merged my last change by 
hand and missed that accidentally.




On Friday, November 15, 2002, at 06:48 PM, George Schlossnagle wrote:


Much sexier indeed.  There are some flaws with it:

o  Tokenizes heredocs on whitespace
o  Doesn't count lines correctly for debug (since strings now have 
newlines in them)

Here's a revised patch to yours that fixes those (heredocs are 
tokenized on newlines - I think that is best case)


Andi Gutmans wrote:

I propose something like the following: (not tested)
It's definitely a sexier patch :)

Andi

RCS file: /repository/ZendEngine2/zend_language_scanner.l,v
retrieving revision 1.62
diff -u -u -r1.62 zend_language_scanner.l
--- zend_language_scanner.l 5 Nov 2002 22:01:35 -   1.62
+++ zend_language_scanner.l 15 Nov 2002 23:22:34 -
@@ -474,6 +474,7 @@
 EXPONENT_DNUM  (({LNUM}|{DNUM})[eE][+-]?{LNUM})
 HNUM   "0x"[0-9a-fA-F]+
 LABEL  [a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*
+ENCAPSED_STRING ([a-zA-Z0-9_\x7f-\xff \t\n\r 
#'.:;,()|^&+/*=%!~<>?@]|"-"[^>])+
 WHITESPACE [ \n\r\t]+
 TABS_AND_SPACES [ \t]*
 TOKENS [;:,.\[\]()|^&+-/*=%!~$<>?@]
@@ -1076,6 +1077,12 @@
return T_VARIABLE;
 }

+{ENCAPSED_STRING} {
+   zendlval->value.str.val = (char *)estrndup(yytext, yyleng);
+   zendlval->value.str.len = yyleng;
+   zendlval->type = IS_STRING;
+   return T_STRING;
+}

 {LABEL} {
zendlval->value.str.val = (char *)estrndup(yytext, yyleng);
@@ -1085,7 +1092,7 @@
 }


-{LABEL} {
+{LABEL} {
zendlval->value.str.val = (char *)estrndup(yytext, yyleng);
zendlval->value.str.len = yyleng;
zendlval->type = IS_STRING;
@@ -1374,7 +1381,7 @@
 }


-{ESCAPED_AND_WHITESPACE} {
+{ESCAPED_AND_WHITESPACE} {
HANDLE_NEWLINES(yytext, yyleng);
zendlval->value.str.val = (char *) estrndup(yytext, yyleng);
zendlval->value.str.len = yyleng;



Andi




Index: Zend/zend_language_scanner.l
===
RCS file: /repository/Zend/zend_language_scanner.l,v
retrieving revision 1.54
diff -u -3 -r1.54 zend_language_scanner.l
--- Zend/zend_language_scanner.l	13 Nov 2002 03:28:23 -	1.54
+++ Zend/zend_language_scanner.l	15 Nov 2002 23:47:29 -
@@ -95,7 +95,7 @@
 \
 	while (p
 		if (*p == '\n') {		\
-			CG(zend_lineno)++;	\
+		CG(zend_lineno)++;	\
 		} else if ((*p == '\r') && (p+1 < boundary) && (*(p+1) != '\n')) 
{		\
 			CG(zend_lineno)++;	\
 		}		\
@@ -707,6 +707,8 @@
 EXPONENT_DNUM	(({LNUM}|{DNUM})[eE][+-]?{LNUM})
 HNUM	"0x"[0-9a-fA-F]+
 LABEL	[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*
+ENCAPSED_STRING ([a-zA-Z0-9_\x7f-\xff \t 
#'.:;,()|^&+/*=%!~<>?@]|"-"[^>])+
+ENCAPSED_STRING_WITH_NEWLINE ([a-zA-Z0-9_\x7f-\xff \t\n\r 
#'.:;,()|^&+/*=%!~<>?@]|"-"[^>])+
 WHITESPACE [ \n\r\t]+
 TABS_AND_SPACES [ \t]*
 TOKENS [;:,.\[\]()|^&+-/*=%!~$<>?@]
@@ -1287,6 +1289,13 @@
 	return T_VARIABLE;
 }

+{ENCAPSED_STRING_WITH_NEWLINE} {
+   HANDLE_NEWLINES(yytext, yyleng);
+   zendlval->value.str.val = (char *)estrndup(yytext, yyleng);
+   zendlval->value.str.len = yyleng;
+   zendlval->type = IS_STRING;
+   return T_STRING;
+}

 {LABEL} {
  	zend_copy_value(zendlval, yytext, yyleng);
@@ -1295,7 +1304,7 @@
 }


-{LABEL} {
+{ENCAPSED_STRING} {
  	zend_copy_value(zendlval, yytext, yyleng);
 	zendlval->type = IS_STRING;
 	return T_STRING;
@@ -1598,7 +1607,7 @@
 }


-{ESCAPED_AND_WHITESPACE} {
+{ESCAPED_AND_WHITESPACE} {
 	HANDLE_NEWLINES(yytext, yyleng);
 	zendlval->value.str.val = (char *) estrndup(yytext, yyleng);
 	zendlval->value.str.len = yyleng;

--
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, visit: http://www.php.net/unsub.php
-- 
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP-DEV] ZEND_ADD_STRING patch

2002-11-16 Thread George Schlossnagle
Here's the patch.  Looks like everything but the heredoc part is in cvs 
now.






-- 
PHP Development Mailing List 
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP-DEV] Capturing headers with output buffering?

2002-11-24 Thread George Schlossnagle
What are you trying to accomplish?


On Sunday, November 24, 2002, at 05:40 PM, David Brown wrote:


Hi:

Architecturally speaking, is there any simple way to modify an sapi
backend to return HTTP headers through the output buffering mechanism?

As far as I can tell, headers are managed seperately by main/output.c,
with php_ub_body_write_no_header being substituted in once the HTTP
headers are sent.

Pointers to anything would be greatly appreciated.

TIA,
- Dave


--
PHP Development Mailing List 
To unsubscribe, visit: http://www.php.net/unsub.php




--
PHP Development Mailing List 
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP-DEV] Capturing headers with output buffering?

2002-11-24 Thread George Schlossnagle
Bad idea or not (I don't think it will be fast and there are some 
problems with some of the  ideas you want to pull off, imho) I 
certainly believe that reinventing the wheel can be a healthy exercise.

That having been said, most of what you want to accomplish here 
requires a single lon-living process.  php only sends headers once per 
request/c[lg]i invocations , so this won't do what you're hoping for.

Seems to me that you would want to do something like this, using the 
cli:

startup
listen
while 1:
	accept
	read request
	set buffering true
	use a userspace function to generate headers
	use a userspace function to generate body
	capture buffer
	close buffer
	send captured buffer over socket


You should be able to modify the sapi functions to buffer headers as 
well, but a) then your server is written in C, not in php and b) I 
think this isn't useful for too many applications.

George


On Sunday, November 24, 2002, at 06:06 PM, David Brown wrote:

Hi George:

It's something that's probably better solved in user-space, but I
figured I'd poke around anyway. :)

I'm attempting to write a little prefork HTTP server entirely in PHP.
The script instansiates an 'application class', which is persistent
across requests. Output of the application is captured with an ob_*
callback function, and then stuffed down a socket. I'm hoping for free
in-memory opcode caching and database connection persistence (by virtue
of recycling the same interpreter across multiple requests), and
possibly the elimination of a lot of application-specific startup time.

Of course, this whole thing could very well just be a bad idea. :)

Anyway, headers aren't currently included in the buffered output, which
causes the header() function to print to stdout, effectively doing
nothing. I could just wrap header() with a user-space function, but 
that
would prevent a lot of scripts from running as-is.

Bad idea? Maybe. There's also the matter of getting it to parse
POST/GET without completely reinventing the wheel...

- Dave


On Sun, Nov 24, 2002 at 05:57:33PM -0500, George Schlossnagle wrote:
| What are you trying to accomplish?
|
|
| On Sunday, November 24, 2002, at 05:40 PM, David Brown wrote:
|
| >Hi:
| >
| >Architecturally speaking, is there any simple way to modify an sapi
| >backend to return HTTP headers through the output buffering 
mechanism?
| >
| >As far as I can tell, headers are managed seperately by 
main/output.c,
| >with php_ub_body_write_no_header being substituted in once the HTTP
| >headers are sent.
| >
| >Pointers to anything would be greatly appreciated.
| >
| >TIA,
| >- Dave
| >
| >
| >--
| >PHP Development Mailing List <http://www.php.net/>
| >To unsubscribe, visit: http://www.php.net/unsub.php
| >
|
|


--
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP-DEV] [PATCH] Redirect on Error

2002-11-25 Thread George Schlossnagle
I'm not really arguing for or against this, but since when did speaking 
english become a corollary of being intelligent?  And even if we accept 
the rather ridiculous hypotheis that all php developers can comprehend 
english, what if they don't want to, or are more confident using their 
native tongue in day-to-day work?  Why deny that to them on prinicple?

Plenty of products support multi-lingual errors in the way John 
describes.  In fact there's an argument that constant-based error codes 
are even easier to describe than verobose english descriptions, as they 
leave no room for ambiguity due to re-phrasing.



Daniel Lorch wrote:

hi,


   Daniel, Sterling is arguing in favor of having localized
   error messages.



s/agree/disagree/ :)

Do what you think is right. However, I think it just adds another level of
unnecessary complexity. We can safely assume a certain level of intelligence
when dealing with php developers ("developers" as in "developing IN PHP").
PHP is not a application as in "Windows XP" or "Media Player", but it's a
development environment where the users necessarily has to be confronted
with a couple of error messages. For the sake of brevity, these are kept
in english and this shouldn't change, IMAO. 

Developers don't have to be spoon-fed. Really.

-daniel





--
PHP Development Mailing List 
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP-DEV] [PATCH] Redirect on Error

2002-11-25 Thread George Schlossnagle
Is your claim that db2 has no international error messages? It does, or 
did last I checked.  Or was it that SQLServer doesn't either (it does 
as well).


On Monday, November 25, 2002, at 08:24 PM, Ilia A. wrote:

On November 25, 2002 08:15 pm, Maxim Maletsky wrote:

On Tue, 26 Nov 2002 00:30:55 +0200 (EET) Jani Taskinen <[EMAIL PROTECTED]>

wrote:

Just forget this. I'm not native english speaker, but I REALLY
don't want to see any errors in any other language but english.
(does Perl/Python/etc have multi-lingual errors btw?)

--Jani


The world's most powerful database server does - Oracle. And, just 
type
something out of the place and you will get them dozens :)

That's arguable, there are many people who would say the same about 
IBM's DB2.
According to TPC 
(http://www.tpc.org/tpcc/results/tpcc_perf_results.asp)
Microsoft SQL Server 2000 is faster and has lower cost per 
transaction. So
claims about greatness of Oracle and greatly exaggerated.

Ilia

--
PHP Development Mailing List 
To unsubscribe, visit: http://www.php.net/unsub.php



--
PHP Development Mailing List 
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP-DEV] [PATCH] Redirect on Error

2002-11-25 Thread George Schlossnagle
MySQL also supports error message internationalization - one more RDBMS 
to annoy Sterling, I guess.

George

On Monday, November 25, 2002, at 08:47 PM, Maxim Maletsky wrote:


It was to say that these three (Oracle, SQL and DB2) do have
internationalized error reporting. I meant them as an example for the
one PHP has.

--
Maxim Maletsky
[EMAIL PROTECTED]


On Mon, 25 Nov 2002 20:44:03 -0500 George Schlossnagle 
<[EMAIL PROTECTED]> wrote:

Is your claim that db2 has no international error messages? It does, 
or
did last I checked.  Or was it that SQLServer doesn't either (it does
as well).


On Monday, November 25, 2002, at 08:24 PM, Ilia A. wrote:

On November 25, 2002 08:15 pm, Maxim Maletsky wrote:

On Tue, 26 Nov 2002 00:30:55 +0200 (EET) Jani Taskinen 
<[EMAIL PROTECTED]>
wrote:

Just forget this. I'm not native english speaker, but I REALLY
don't want to see any errors in any other language but english.
(does Perl/Python/etc have multi-lingual errors btw?)

--Jani


The world's most powerful database server does - Oracle. And, just
type
something out of the place and you will get them dozens :)


That's arguable, there are many people who would say the same about
IBM's DB2.
According to TPC
(http://www.tpc.org/tpcc/results/tpcc_perf_results.asp)
Microsoft SQL Server 2000 is faster and has lower cost per
transaction. So
claims about greatness of Oracle and greatly exaggerated.

Ilia

--
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, visit: http://www.php.net/unsub.php




--
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, visit: http://www.php.net/unsub.php






--
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP-DEV] [PATCH] Redirect on Error

2002-11-25 Thread George Schlossnagle
Oh, I'm sorry, I didn't realize you were going off-topic to pick at 
parts of Maxim's argument.  My mistake.

George

On Monday, November 25, 2002, at 08:52 PM, Ilia A. wrote:

On November 25, 2002 08:44 pm, George Schlossnagle wrote:

Is your claim that db2 has no international error messages? It does, 
or
did last I checked.  Or was it that SQLServer doesn't either (it does
as well).

Uhm, did I say anything about i18n in DB2 or  SQLServer, no. I merely 
pointed
out that Oracle's status as most powerful database is in the eye of the
beholder.

Ilia

On Monday, November 25, 2002, at 08:24 PM, Ilia A. wrote:

On November 25, 2002 08:15 pm, Maxim Maletsky wrote:

On Tue, 26 Nov 2002 00:30:55 +0200 (EET) Jani Taskinen 
<[EMAIL PROTECTED]>

wrote:

Just forget this. I'm not native english speaker, but I REALLY
don't want to see any errors in any other language but english.
(does Perl/Python/etc have multi-lingual errors btw?)

--Jani


The world's most powerful database server does - Oracle. And, just
type
something out of the place and you will get them dozens :)


That's arguable, there are many people who would say the same about
IBM's DB2.
According to TPC
(http://www.tpc.org/tpcc/results/tpcc_perf_results.asp)
Microsoft SQL Server 2000 is faster and has lower cost per
transaction. So
claims about greatness of Oracle and greatly exaggerated.

Ilia

--
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, visit: http://www.php.net/unsub.php



--
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, visit: http://www.php.net/unsub.php




--
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP-DEV] [PATCH] Redirect on Error

2002-11-25 Thread George Schlossnagle

By the way, could you please advise by how much I will need to 
increase the
power of my server(s) to maintain the same level of performance?

Why would this need to kill your performance if you're not throwing 
errors?


--
PHP Development Mailing List 
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DEV] [PATCH] Redirect on Error

2002-11-25 Thread George Schlossnagle
There is no proposed patch to affect all these changes.  There are fine 
ways to print errors that don't necessitate having them loaded at run 
time.  They could be in a dbm file, or even a flat file hierarchy and 
loaded on demand.  This would not be as fast as a hash table, but when 
you're actually printing errors, a slight overhead seems acceptable (to 
me, ymmv)



On Monday, November 25, 2002, at 10:27  PM, Ilia A. wrote:

On November 25, 2002 09:59 pm, George Schlossnagle wrote:

By the way, could you please advise by how much I will need to
increase the
power of my server(s) to maintain the same level of performance?


Why would this need to kill your performance if you're not throwing
errors?


Because errors need to be loaded into memory by some mechanism, stored 
in a
hash table? Meaning that during startup I will be penalized for this 
process.
Hash table has it own overhead as well meaning that PHP memory usage 
will
increase, for a server running 200-300 apache children constantly even 
a
small increase will count.
This will also make PHP shell scripting impractical due to the high 
start
costs of a PHP binary.

Ilia


--
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP-DEV] [PATCH] Redirect on Error

2002-11-25 Thread George Schlossnagle

On Monday, November 25, 2002, at 10:43  PM, Ilia A. wrote:


On November 25, 2002 10:30 pm, George Schlossnagle wrote:

There is no proposed patch to affect all these changes.  There are 
fine
ways to print errors that don't necessitate having them loaded at run
time.  They could be in a dbm file, or even a flat file hierarchy and
loaded on demand.  This would not be as fast as a hash table, but when
you're actually printing errors, a slight overhead seems acceptable 
(to
me, ymmv)

If we were talking about a one time script that is execute and forget 
then you
are absolutely right. But what about if a web server enviroment where a
child/thread can remain in memory indefinitely. Or a web hosting 
enviroment
where the admin has no control over the script of the users, loading &
(unloading?) of the error messages database will add overall overhead 
non the
less.

dbm lookups are fast, as are (to a lesser extent) file system lookups.  
Neither consume any process memory.  Neither require an entire database 
to be loaded, simply to have the entry looked up in them.

And if you're running an hosting service for users, performance is sort 
of out the window anyway.


This is also not as easy as it sounds, for example a gettext a commonly
used tool for localizations, is not thread safe, so we are looking at 
having
to design a error localization mechanism with a thread safe disk 
database
system.

Well, fortunately, this being an open-source project this burden need 
not lie with you if you don't want it to.

I'm somewhere between +0 and +1 on this issue.  I think it would be 
helpful, a nice feature to have. and generally increase accessibility.  
I don't think that an implementation would necessarily incur overhead 
unless error functions are being called.

George


--
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DEV] [PATCH] Redirect on Error

2002-11-25 Thread George Schlossnagle

On Monday, November 25, 2002, at 11:29  PM, Ilia A. wrote:


On November 25, 2002 10:57 pm, George Schlossnagle wrote:

On Monday, November 25, 2002, at 10:43  PM, Ilia A. wrote:

On November 25, 2002 10:30 pm, George Schlossnagle wrote:

There is no proposed patch to affect all these changes.  There are
fine
ways to print errors that don't necessitate having them loaded at 
run
time.  They could be in a dbm file, or even a flat file hierarchy 
and
loaded on demand.  This would not be as fast as a hash table, but 
when
you're actually printing errors, a slight overhead seems acceptable
(to
me, ymmv)

If we were talking about a one time script that is execute and forget
then you
are absolutely right. But what about if a web server enviroment 
where a
child/thread can remain in memory indefinitely. Or a web hosting
enviroment
where the admin has no control over the script of the users, loading 
&
(unloading?) of the error messages database will add overall overhead
non the
less.

dbm lookups are fast, as are (to a lesser extent) file system lookups.
Neither consume any process memory.  Neither require an entire 
database
to be loaded, simply to have the entry looked up in them.

Nearly any singular operation is fast, the question is what happens 
when it is
done often. For a database stored on disk we are talking at least 2-3 
drive
seeks + reading of meta information at the start of the database. 
While it
may be negligible for a single process it does add up. Given that this 
done
rarely (hopefuly) it would not result in major performance loss, 
however
there will be a performance loss non the less.

If you're throwing errors your script isn't working right anyway.  
syslog() logging is also extremely slow, especially if you're logging 
to a network host, but that's still supported in php.  There are plenty 
of shocking inefficiencies in php.  Adding one in the case of user 
error (which if you're running a site where an extra 3 drive seeks per 
error is a serious issue you should be disciplined enough not to be 
having at all) seems like a pittance to me.



Well, fortunately, this being an open-source project this burden need
not lie with you if you don't want it to.


I dislike the idea because I believe this idea is going to make PHP 
more
confusing and ultimately harder to use, which is the exact opposite of 
what
this change attempts to accomplish. Fortunately this being an 
open-source
project it is also possible to make your own version free of bloat :)


It's hard for me to decide whether this is bloat or not.  2700-some 
builtin functions shipping with php seems much more like bloat to me 
than providing option i18n error messages to people who would prefer to 
read them.


--
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DEV] call_stack

2002-11-27 Thread George Schlossnagle
debug_backtrace was backported into ze1.  4.3 will sstill use ze1.

George

Phil Dier wrote:


On Wed, 27 Nov 2002 15:41:25 +0100 (CET)
Derick Rethans <[EMAIL PROTECTED]> wrote:


On Wed, 27 Nov 2002, Miham KEREKES wrote:


Hi!

I'm new to this list, I want to know if there is any function which
could return the actual call stack, or is it planned to be added?
It could be very useful (for example in my case, now :-).


debug_backtrace() will be available in PHP 4.3.0 and higher.

Derick



I thought debug_backtrace() was a ze2 thing.  Does that mean 4.3 is going to
use ze2?

Phil Dier






--
PHP Development Mailing List 
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP-DEV] call_stack

2002-11-27 Thread George Schlossnagle
I'll do it, if you want.

Andi Gutmans wrote:


At 07:23 PM 11/27/2002 +0100, Derick Rethans wrote:


On Wed, 27 Nov 2002, Andi Gutmans wrote:

> At 03:41 PM 11/27/2002 +0100, Derick Rethans wrote:
> >On Wed, 27 Nov 2002, Miham KEREKES wrote:
> >
> >debug_backtrace() will be available in PHP 4.3.0 and higher.
>
> if someone has time to implement debug_print_backtrace() that would be
> cool. Using the raw debug_backtrace() is a bitch.

If you're trying to volunteer me it's not going to work :P



Damn! Maybe someone else? :)

Andi




--
PHP Development Mailing List 
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP-DEV] call_stack

2002-11-27 Thread George Schlossnagle
Is there a concensus on how arguments should be printed out?

I'm shooting right now for a 'cluck' style backtrave

class::function() called at file:line


Perhaps

class::function() called at file:line
   Arguments:
   print_r(args)

??


Andi Gutmans wrote:


That'd be cool.

At 01:32 PM 11/27/2002 -0500, George Schlossnagle wrote:


I'll do it, if you want.

Andi Gutmans wrote:


At 07:23 PM 11/27/2002 +0100, Derick Rethans wrote:


On Wed, 27 Nov 2002, Andi Gutmans wrote:

> At 03:41 PM 11/27/2002 +0100, Derick Rethans wrote:
> >On Wed, 27 Nov 2002, Miham KEREKES wrote:
> >
> >debug_backtrace() will be available in PHP 4.3.0 and higher.
>
> if someone has time to implement debug_print_backtrace() that 
would be
> cool. Using the raw debug_backtrace() is a bitch.

If you're trying to volunteer me it's not going to work :P



Damn! Maybe someone else? :)

Andi











--
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP-DEV] call_stack

2002-11-27 Thread George Schlossnagle
Hmmm  any hints on how to get the variable name out of the stack? 
The code in debug_backtrace seems to only extract the value.

George

Andi Gutmans wrote:

I'd probably go for class::function($arg1, $arg2).
Also take into consideration that the args aren't always available.

Andi

At 02:58 PM 11/27/2002 -0500, George Schlossnagle wrote:


Is there a concensus on how arguments should be printed out?

I'm shooting right now for a 'cluck' style backtrave

class::function() called at file:line


Perhaps

class::function() called at file:line
   Arguments:
   print_r(args)

??


Andi Gutmans wrote:


That'd be cool.

At 01:32 PM 11/27/2002 -0500, George Schlossnagle wrote:


I'll do it, if you want.

Andi Gutmans wrote:


At 07:23 PM 11/27/2002 +0100, Derick Rethans wrote:


On Wed, 27 Nov 2002, Andi Gutmans wrote:

> At 03:41 PM 11/27/2002 +0100, Derick Rethans wrote:
> >On Wed, 27 Nov 2002, Miham KEREKES wrote:
> >
> >debug_backtrace() will be available in PHP 4.3.0 and higher.
>
> if someone has time to implement debug_print_backtrace() that 
would be
> cool. Using the raw debug_backtrace() is a bitch.

If you're trying to volunteer me it's not going to work :P




Damn! Maybe someone else? :)

Andi
















--
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP-DEV] call_stack

2002-11-27 Thread George Schlossnagle
Ok... but that looks nasty when you are passed an array or an object.



Andi Gutmans wrote:


At 03:13 PM 11/27/2002 -0500, George Schlossnagle wrote:


Hmmm  any hints on how to get the variable name out of the stack? 
The code in debug_backtrace seems to only extract the value.


There's no way but I don't think it's needed. When I wrote $arg1 I 
meant the value not the name of the variable. Sorry if I wasn't clear.
Andi


George

Andi Gutmans wrote:


I'd probably go for class::function($arg1, $arg2).
Also take into consideration that the args aren't always available.

Andi

At 02:58 PM 11/27/2002 -0500, George Schlossnagle wrote:


Is there a concensus on how arguments should be printed out?

I'm shooting right now for a 'cluck' style backtrave

class::function() called at file:line


Perhaps

class::function() called at file:line
   Arguments:
   print_r(args)

??


Andi Gutmans wrote:


That'd be cool.

At 01:32 PM 11/27/2002 -0500, George Schlossnagle wrote:


I'll do it, if you want.

Andi Gutmans wrote:


At 07:23 PM 11/27/2002 +0100, Derick Rethans wrote:


On Wed, 27 Nov 2002, Andi Gutmans wrote:

> At 03:41 PM 11/27/2002 +0100, Derick Rethans wrote:
> >On Wed, 27 Nov 2002, Miham KEREKES wrote:
> >
> >debug_backtrace() will be available in PHP 4.3.0 and higher.
>
> if someone has time to implement debug_print_backtrace() that 
would be
> cool. Using the raw debug_backtrace() is a bitch.

If you're trying to volunteer me it's not going to work :P





Damn! Maybe someone else? :)

Andi


















--
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP-DEV] call_stack

2002-11-27 Thread George Schlossnagle
Here's first shot at a patch.  The output it generates is ugly as sin if 
you use objects though.  I though about flattening them out, but that 
gets long and nasty (and requires specialized print functions which 
while easy seem to be of marginal use elsewhere.)

George


Index: Zend/zend_builtin_functions.c
===
RCS file: /repository/Zend/zend_builtin_functions.c,v
retrieving revision 1.127
diff -u -3 -r1.127 zend_builtin_functions.c
--- Zend/zend_builtin_functions.c   27 Nov 2002 20:11:39 -  1.127
+++ Zend/zend_builtin_functions.c   27 Nov 2002 22:42:57 -
@@ -68,6 +68,7 @@
 static ZEND_FUNCTION(get_extension_funcs);
 static ZEND_FUNCTION(get_defined_constants);
 static ZEND_FUNCTION(debug_backtrace);
+static ZEND_FUNCTION(debug_print_backtrace);
 #if ZEND_DEBUG
 static ZEND_FUNCTION(zend_test_func);
 #endif
@@ -122,6 +123,7 @@
ZEND_FE(get_extension_funcs,NULL)
ZEND_FE(get_defined_constants,  NULL)
ZEND_FE(debug_backtrace,NULL)
+   ZEND_FE(debug_print_backtrace,  NULL)
 #if ZEND_DEBUG
ZEND_FE(zend_test_func, NULL)
 #endif
@@ -1171,6 +1173,151 @@
add_next_index_zval(arg_array, *arg);
}
return arg_array;
+}
+
+
+void debug_print_backtrace_args(zval *arg_array) 
+{
+zval **tmp;
+HashPosition iterator;
+int i = 0;
+
+zend_hash_internal_pointer_reset_ex(arg_array->value.ht, &iterator);
+while (zend_hash_get_current_data_ex(arg_array->value.ht, (void **) &tmp, 
+&iterator) == SUCCESS) {
+   if(i++) {
+   ZEND_PUTS(",");
+   }
+   zend_print_zval_r(*tmp, 4);
+   zend_hash_move_forward_ex(arg_array->value.ht, &iterator);
+}
+}
+
+/* {{{ proto void debug_backtrace(void)
+   Prints out a backtrace */
+ZEND_FUNCTION(debug_print_backtrace)
+{
+   zend_execute_data *ptr;
+   int lineno;
+   char *function_name;
+   char *filename;
+   char *class_name;
+   char *call_type;
+   char *include_filename = NULL;
+   zval *stack_frame;
+   zval *arg_array;
+   void **cur_arg_pos = EG(argument_stack).top_element;
+   void **args = cur_arg_pos;
+   int arg_stack_consistent = 0;
+   int frames_on_stack = 0;
+   int indent = 0;
+   int i;
+
+   if (ZEND_NUM_ARGS()) {
+   ZEND_WRONG_PARAM_COUNT();
+   }
+
+   while (--args >= EG(argument_stack).elements) {
+   if (*args--) {
+   break;
+   }
+   args -= *(ulong*)args;
+   frames_on_stack++;
+
+   if (args == EG(argument_stack).elements) {
+   arg_stack_consistent = 1;
+   break;
+   }
+   }
+
+   ptr = EG(current_execute_data);
+
+   /* skip debug_backtrace() */
+   ptr = ptr->prev_execute_data;
+   cur_arg_pos -= 2;
+   frames_on_stack--;
+
+   array_init(return_value);
+
+   while (ptr) {
+   if (ptr->op_array) {
+   filename = ptr->op_array->filename;
+   lineno = ptr->opline->lineno;
+   } else {
+   filename = NULL;
+   }
+
+   function_name = ptr->function_state.function->common.function_name;
+
+   if (function_name) {
+   if (ptr->ce) {
+   class_name = ptr->ce->name;
+   call_type = "::";
+   } else if (ptr->object.ptr) {
+   class_name = ptr->object.ptr->value.obj.ce->name;
+   call_type = "->";
+   } else {
+   class_name = NULL;
+   call_type = NULL;
+   }
+   if ((! ptr->opline) || ((ptr->opline->opcode == 
+ZEND_DO_FCALL_BY_NAME) || (ptr->opline->opcode == ZEND_DO_FCALL))) {
+   if (arg_stack_consistent && (frames_on_stack > 0)) {
+   arg_array = 
+debug_backtrace_get_args(&cur_arg_pos TSRMLS_CC);
+   frames_on_stack--;
+   }
+   }   
+   } else {
+   /* i know this is kinda ugly, but i'm trying to avoid extra 
+cycles in the main execution loop */
+   zend_bool build_filename_arg = 1;
+
+   switch (ptr->opline->op2.u.constant.value.lval) {
+   case ZEND_EVAL:
+   function_name = "eval";
+   build_filename_arg = 0;
+   break;
+   case ZEND_INCLUDE:
+   fu

Re: [PHP-DEV] call_stack

2002-11-27 Thread George Schlossnagle
And here is a version which flattens the calling args onto a single line 
(similar to sebastians usersapce script).  Longer, but a bit prettier 
output.



Index: Zend/zend.c
===
RCS file: /repository/Zend/zend.c,v
retrieving revision 1.163
diff -u -3 -r1.163 zend.c
--- Zend/zend.c 17 Nov 2002 13:26:36 -  1.163
+++ Zend/zend.c 27 Nov 2002 23:07:00 -
@@ -138,6 +138,35 @@
 }
 
 
+static void print_flat_hash(HashTable *ht)
+{
+   zval **tmp;
+   char *string_key;
+   HashPosition iterator;
+   ulong num_key;
+   uint str_len;
+   int i = 0;
+
+   zend_hash_internal_pointer_reset_ex(ht, &iterator);
+   while (zend_hash_get_current_data_ex(ht, (void **) &tmp, &iterator) == 
+SUCCESS) {
+   if(i++ > 0) {
+   ZEND_PUTS(",");
+   }
+   ZEND_PUTS("[");
+   switch (zend_hash_get_current_key_ex(ht, &string_key, &str_len, 
+&num_key, 0, &iterator)) {
+   case HASH_KEY_IS_STRING:
+   ZEND_PUTS(string_key);
+   break;
+   case HASH_KEY_IS_LONG:
+   zend_printf("%ld", num_key);
+   break;
+   }
+   ZEND_PUTS("] => ");
+   zend_print_flat_zval_r(*tmp);
+   zend_hash_move_forward_ex(ht, &iterator);
+   }
+}
+
 ZEND_API void zend_make_printable_zval(zval *expr, zval *expr_copy, int *use_copy)
 {
if (expr->type==IS_STRING) {
@@ -215,6 +244,43 @@
 }
 
 
+ZEND_API void zend_print_flat_zval_r(zval *expr)
+{
+   zend_write_func_t write_func = zend_write;
+
+   switch(expr->type) {
+   case IS_ARRAY:
+   ZEND_PUTS("Array (");
+   if (++expr->value.ht->nApplyCount>1) {
+   ZEND_PUTS(" *RECURSION*");
+   expr->value.ht->nApplyCount--;
+   return;
+   }
+   print_flat_hash(expr->value.ht);
+   ZEND_PUTS(")");
+   expr->value.ht->nApplyCount--;
+   break;
+   case IS_OBJECT:
+   {
+   zend_object *object = Z_OBJ_P(expr);
+
+   if (++object->properties->nApplyCount>1) {
+   ZEND_PUTS(" *RECURSION*");
+   object->properties->nApplyCount--;
+   return;
+   }
+   zend_printf("%s Object (", object->ce->name);
+   print_flat_hash(object->properties);
+   ZEND_PUTS(")");
+   object->properties->nApplyCount--;
+   break;
+   }
+   default:
+   zend_print_variable(expr);
+   break;
+   }
+}
+
 ZEND_API void zend_print_zval_r(zval *expr, int indent)
 {
zend_print_zval_r_ex(zend_write, expr, indent);
@@ -253,6 +319,7 @@
break;
}
 }
+
 
 
 static FILE *zend_fopen_wrapper(const char *filename, char **opened_path)
Index: Zend/zend.h
===
RCS file: /repository/Zend/zend.h,v
retrieving revision 1.166
diff -u -3 -r1.166 zend.h
--- Zend/zend.h 17 Nov 2002 13:26:36 -  1.166
+++ Zend/zend.h 27 Nov 2002 23:07:00 -
@@ -383,6 +383,7 @@
 ZEND_API int zend_print_zval(zval *expr, int indent);
 ZEND_API int zend_print_zval_ex(zend_write_func_t write_func, zval *expr, int indent);
 ZEND_API void zend_print_zval_r(zval *expr, int indent);
+ZEND_API void zend_print_flat_zval_r(zval *expr);
 ZEND_API void zend_print_zval_r_ex(zend_write_func_t write_func, zval *expr, int 
indent);
 ZEND_API void zend_output_debug_string(zend_bool trigger_break, char *format, ...);
 
Index: Zend/zend_builtin_functions.c
===
RCS file: /repository/Zend/zend_builtin_functions.c,v
retrieving revision 1.127
diff -u -3 -r1.127 zend_builtin_functions.c
--- Zend/zend_builtin_functions.c   27 Nov 2002 20:11:39 -  1.127
+++ Zend/zend_builtin_functions.c   27 Nov 2002 23:07:00 -
@@ -68,6 +68,7 @@
 static ZEND_FUNCTION(get_extension_funcs);
 static ZEND_FUNCTION(get_defined_constants);
 static ZEND_FUNCTION(debug_backtrace);
+static ZEND_FUNCTION(debug_print_backtrace);
 #if ZEND_DEBUG
 static ZEND_FUNCTION(zend_test_func);
 #endif
@@ -122,6 +123,7 @@
ZEND_FE(get_extension_funcs,NULL)
ZEND_FE(get_defined_constants,  NULL)
ZEND_FE(debug_backtrace,NULL)
+   ZEND_FE(debug_print_backt

Re: [PHP-DEV] Reusing PHP string value pointers

2002-11-28 Thread George Schlossnagle
Or use the overload extension in ZE1.   The real question is why you 
really need/want to do this.

George

On Thursday, November 28, 2002, at 04:37  PM, l0t3k wrote:

if you have the option of using  ZE2, make the thing an object and use 
 the
property get/set handlers to take care of things for you

"Marshall A. Greenblatt" <[EMAIL PROTECTED]> wrote in message
000d01c296fe$b0ff82f0$6601a8c0@Marshall">news:000d01c296fe$b0ff82f0$6601a8c0@Marshall...
From: "Zeev Suraski" <[EMAIL PROTECTED]>

When a PHP string variable is changed via a PHP script, such as:

$foo = 'new value';

what happens to the `value.str.val' pointer internally?  Is it 
possible
to

have the new value assigned to the same `value.str.val' pointer that

the

variable is currently using instead of having that pointer replaced 
by
a

pointer to the new value?


No, it's not possible (not in a reliable way anyway).


What about being able to register a callback function for variable
assignment?  That way I can keep track of the pointer myself and copy 
the
new value to it when the variable value is changed in the PHP script.
Would

anybody else be interested in this functionality?



Zeev



Thanks,
  Marshall





--
PHP Development Mailing List 
To unsubscribe, visit: http://www.php.net/unsub.php




--
PHP Development Mailing List 
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP-DEV] C++ extensions and ext_skel

2002-11-28 Thread George Schlossnagle
I concur, that would be cool.  Patches should be against HEAD.

George

On Thursday, November 28, 2002, at 05:33  PM, Shane Caraveo wrote:


I think that would be quite cool, save me from having to do it manualy.
Shane

J Smith wrote:

A couple of times a month, I get questions about from people looking 
to use C++ with PHP. Apparently, a lot of people end up reading some 
post I made to php.dev or something a year or so ago about C++, and 
although it worked at the time, the procedure I describe has become 
stale.
I messed around a bit with ext_skel and ext/skeleton today and added 
an option to ext_skel (--cpp) that creates a basic C++ extension 
rather than the standard C extension. The C++ extension is pretty 
much the same as the standard C extension, with the exception of some 
extern "C" linkage, modifications to config.m4 and Makefile.in and a 
small C++ class thrown in for fun.
Would this be worth adding to PHP proper? I have patches available 
for 4.2.3, but if it's worthy, I can whip it up for 4.3 or whatever. 
It'll save me some email bandwidth if it could be used.
J



--
PHP Development Mailing List 
To unsubscribe, visit: http://www.php.net/unsub.php




--
PHP Development Mailing List 
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP-DEV] Zend fast cache

2002-11-30 Thread George Schlossnagle
How does searching the freelist work in this? How is this faster than 
say a 3-level page table implementation?

That said, I do think that if we can get very fast code to pre-allocate 
zval's it would be a good idea (hopefully we could get more than 5% 
increase).
I already have an idea for how I would want such an API to look like 
and I was planning to write it. It would also be useful for Zend 
objects which are preallocated today but if a realloc() were to be 
reached it would take quite some time (although one or two realloc()'s 
wouldn't be terrible).
My idea is a two dimensional array. We'd allocate 2^n of memory blocks 
and assign it to array[0]. Once these are full we'd allocate another 
2^n memory blocks and realloc() array to size of 2 and make array[1] 
point to it. The index to a block would be X and to find the right 
position it'd be array[X/2^n][X%2^n] of course as the length of each 
array is a power of two we wouldn't actually need to use division and 
modulo so it'd be fast.
As we don't have templates in C we might be able to put all of this 
inline in a header file and with macros create such a fast allocating 
pool for some of the most used types specifically I think it'd be 
useful for zval's, objects and possible hash tables. I wouldn't overdo 
the amount of types I'd add to this pool because unless they are 
allocated and freed extremely often we wouldn't notice a speed 
difference.

But remember what I said about 5% :)
Andi


--
PHP Development Mailing List 
To unsubscribe, visit: http://www.php.net/unsub.php



--
PHP Development Mailing List 
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP-DEV] Zend fast cache

2002-11-30 Thread George Schlossnagle
The problem I see with an array approach from an api perspective is 
simply when a bucket
is free'd, in order to have efficient memory usage, we'd need a second 
level array scan
for every ALLOC_ZVAL().

Perhaps a linked list would be a better choice for this, as we can 
just be smart about bucket
access, and eliminate the need for a scan (could be possible I'm 
missing something?)

A number of memory allocators use a multi-tiered page table for this.  
basically for each object type you have a array of N pointers to level 
1 objects and a freelist for them, basically tier one has N elements 
that each contain a freelist bitmask value and an array of pointers to 
level 2 objects.  Level 2 objects have a freelist of N allocations for 
the desired object type and pointers to each of them.  This may be what 
Andi was talking about, but it wasn't clear to me from his description.

So you get N^3 aloocations you can track, and a freelist search 
involves looking at 3 bitmasks.  Significantly faster than a linked 
list implementation.  By keeping a separate tree for each allocation 
type (or at least allocation size), you also end up with basically no 
fragmentation.



-Sterling

--
PHP Development Mailing List 
To unsubscribe, visit: http://www.php.net/unsub.php




--
PHP Development Mailing List 
To unsubscribe, visit: http://www.php.net/unsub.php




  1   2   >