You are viewing a plain text version of this content. The canonical link for it is here.
Posted to embperl@perl.apache.org by RobertCZ <ro...@robert.cz> on 2004/11/22 11:09:56 UTC

AIM/mp2 Apache::compat bug?

Hi,

  I'm playing with Apache::ImageMagick under mod_perl 2 and 
Apache::compat (mainly because AIM needs Apache::File which is not 
supported under mp2). AIM/mp2 returns the correct modified file but with 
wrong file size (size of the original file, not the modified one). It 
does work under mod_perl 1, could this be Apache::compat bug? If yes, 
any idea how it could  fixed? Thanks.

- Robert


-------------

janosik tmp # wget -t 1 
'http://adria.germic.sk/img/photo/koup0405.jpg/Scale?width=100&height=100'                                                                                                 

--11:01:17--  
http://adria.germic.sk/img/photo/koup0405.jpg/Scale?width=100&height=100
           => `Scale?width=100&height=100'
Resolving adria.germic.sk... 81.0.228.181
Connecting to adria.germic.sk[81.0.228.181]:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 104,479 [image/jpeg]
 
17% 
[=========================>                                                                                                                              
] 18,448        --.--K/s            
 
11:01:17 (187.16 MB/s) - Connection closed at byte 18448. Giving up.
 
janosik tmp # wget -t 1 
'http://adria.germic.sk/img/photo/koup0405.jpg'                                                                                                                            

--11:01:26--  http://adria.germic.sk/img/photo/koup0405.jpg
           => `koup0405.jpg.3'
Resolving adria.germic.sk... 81.0.228.181
Connecting to adria.germic.sk[81.0.228.181]:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 104,479 [image/jpeg]
 
100%[=======================================================================================================================================================>] 
104,479       --.--K/s            
 
11:01:26 (174.81 MB/s) - `koup0405.jpg.3' saved [104479/104479]


-------------


---------------------------------------------------------------------
To unsubscribe, e-mail: embperl-unsubscribe@perl.apache.org
For additional commands, e-mail: embperl-help@perl.apache.org


Re: AIM/mp2 Apache::compat bug?

Posted by Stas Bekman <st...@stason.org>.
Geoffrey Young wrote:
>>>what _does_ need to happen, though, is for Apache::compat to redefine
>>>filename() so that it behaves like mp1 did.  I just don't have the
>>>tuits at
>>>the moment.
>>
>>
>>Right, but there are issues with doing that:
>>
>>1) that should probably be overridable and not loaded by default:
>>http://perl.apache.org/docs/2.0/api/Apache/compat.html#Compatibility_Functions_Colliding_with_mod_perl_2_0_API
>>
>>since if not it'll replace the real mp2 API and may be someone doesn't
>>want the stat struct to be updated.
> 
> 
> yup.
> 
> 
>>2) filename() should behave differently depending on which phase was it
>>called from. What if someone just sets filename() to skip the stat
>>calls? Should it still call the finfo update?
> 
> 
> I'd think so - this is a compat layer, and mod_perl updated finfo blindly on
> each $r->filename call.  it also updated _ with the new stat information, so
> compat.pm should do that as well.

Now fixed in Apache::compat. The docs will be updated shortly.


-- 
__________________________________________________________________
Stas Bekman            JAm_pH ------> Just Another mod_perl Hacker
http://stason.org/     mod_perl Guide ---> http://perl.apache.org
mailto:stas@stason.org http://use.perl.org http://apacheweek.com
http://modperlbook.org http://apache.org   http://ticketmaster.com

-- 
Report problems: http://perl.apache.org/bugs/
Mail list info: http://perl.apache.org/maillist/modperl.html
List etiquette: http://perl.apache.org/maillist/email-etiquette.html


Re: AIM/mp2 Apache::compat bug?

Posted by Geoffrey Young <ge...@modperlcookbook.org>.
>> what _does_ need to happen, though, is for Apache::compat to redefine
>> filename() so that it behaves like mp1 did.  I just don't have the
>> tuits at
>> the moment.
> 
> 
> Right, but there are issues with doing that:
> 
> 1) that should probably be overridable and not loaded by default:
> http://perl.apache.org/docs/2.0/api/Apache/compat.html#Compatibility_Functions_Colliding_with_mod_perl_2_0_API
> 
> since if not it'll replace the real mp2 API and may be someone doesn't
> want the stat struct to be updated.

yup.

> 
> 2) filename() should behave differently depending on which phase was it
> called from. What if someone just sets filename() to skip the stat
> calls? Should it still call the finfo update?

I'd think so - this is a compat layer, and mod_perl updated finfo blindly on
each $r->filename call.  it also updated _ with the new stat information, so
compat.pm should do that as well.

--Geoff

-- 
Report problems: http://perl.apache.org/bugs/
Mail list info: http://perl.apache.org/maillist/modperl.html
List etiquette: http://perl.apache.org/maillist/email-etiquette.html


Re: AIM/mp2 Apache::compat bug?

Posted by Stas Bekman <st...@stason.org>.
Geoffrey Young wrote:
>>I'd like the option argument, because I'm sure people will run into this
>>many times.
> 
> 
> well, as we're starting to discuss over on dev@,

since you commented here, let's just finish it here rather than speading 
it all over.

> I'm not really in favor of
> an optional argument.  if you know that you need to pass the additional
> argument, then you know enough to make the APR::Finfo::stat() call yourself
> - the reasons for needing to call stat() are (now) documented, so I'd much
> rather not be doing any magic behind the scenes that can't be handled by the
> existing API.  it was actually this issue that prompted me to open up the
> finfo api in the first place, to prevent the need for behind the scenes magic.
> 
> what _does_ need to happen, though, is for Apache::compat to redefine
> filename() so that it behaves like mp1 did.  I just don't have the tuits at
> the moment.

Right, but there are issues with doing that:

1) that should probably be overridable and not loaded by default:
http://perl.apache.org/docs/2.0/api/Apache/compat.html#Compatibility_Functions_Colliding_with_mod_perl_2_0_API
since if not it'll replace the real mp2 API and may be someone doesn't 
want the stat struct to be updated.

2) filename() should behave differently depending on which phase was it 
called from. What if someone just sets filename() to skip the stat calls? 
Should it still call the finfo update?


-- 
__________________________________________________________________
Stas Bekman            JAm_pH ------> Just Another mod_perl Hacker
http://stason.org/     mod_perl Guide ---> http://perl.apache.org
mailto:stas@stason.org http://use.perl.org http://apacheweek.com
http://modperlbook.org http://apache.org   http://ticketmaster.com

-- 
Report problems: http://perl.apache.org/bugs/
Mail list info: http://perl.apache.org/maillist/modperl.html
List etiquette: http://perl.apache.org/maillist/email-etiquette.html


Re: AIM/mp2 Apache::compat bug?

Posted by Geoffrey Young <ge...@modperlcookbook.org>.
>>
> I'd like the option argument, because I'm sure people will run into this
> many times.

well, as we're starting to discuss over on dev@, I'm not really in favor of
an optional argument.  if you know that you need to pass the additional
argument, then you know enough to make the APR::Finfo::stat() call yourself
- the reasons for needing to call stat() are (now) documented, so I'd much
rather not be doing any magic behind the scenes that can't be handled by the
existing API.  it was actually this issue that prompted me to open up the
finfo api in the first place, to prevent the need for behind the scenes magic.

what _does_ need to happen, though, is for Apache::compat to redefine
filename() so that it behaves like mp1 did.  I just don't have the tuits at
the moment.

--Geoff

-- 
Report problems: http://perl.apache.org/bugs/
Mail list info: http://perl.apache.org/maillist/modperl.html
List etiquette: http://perl.apache.org/maillist/email-etiquette.html


Re: AIM/mp2 Apache::compat bug?

Posted by Tom Schindl <to...@gmx.at>.
Stas Bekman wrote:

> That's really a question to httpd developers, mod_perl just provides the 
> perl API for the Apache C API.
> 
> Granted we could do that behind the scenes, but it's not always the 
> desired behavior so I'm not sure we should. May be an option argument 
> could be passed to do the work?
> 
> 
I'd like the option argument, because I'm sure people will run into this 
many times.

Tom

-- 
Report problems: http://perl.apache.org/bugs/
Mail list info: http://perl.apache.org/maillist/modperl.html
List etiquette: http://perl.apache.org/maillist/email-etiquette.html


Re: AIM/mp2 Apache::compat bug?

Posted by Stas Bekman <st...@stason.org>.
Malcolm J Harwood wrote:
> On Tuesday 23 November 2004 11:56 am, Stas Bekman wrote:
> 
> 
>>>>with mp2 you need to update the stat info yourself each time you update
>>>>$r->filename. something like this:
>>>>
>>>> $r->filename($newfile);
>>>> $r->finfo(APR::Finfo::stat($newfile, APR::FINFO_NORM, $r->pool));
> 
> 
>>I've updated the docs to mention that:
>>http://perl.apache.org/docs/2.0/api/Apache/RequestRec.html#C_filename_
> 
> 
> Out of curiosity, what was the reason for the change? I would have thought it 
> is much more prone to user error (people not knowing or forgetting to update 
> the states). Are there cases where you'd change the filename but not need to 
> restat it?

That's really a question to httpd developers, mod_perl just provides the 
perl API for the Apache C API.

Granted we could do that behind the scenes, but it's not always the 
desired behavior so I'm not sure we should. May be an option argument 
could be passed to do the work?


-- 
__________________________________________________________________
Stas Bekman            JAm_pH ------> Just Another mod_perl Hacker
http://stason.org/     mod_perl Guide ---> http://perl.apache.org
mailto:stas@stason.org http://use.perl.org http://apacheweek.com
http://modperlbook.org http://apache.org   http://ticketmaster.com

-- 
Report problems: http://perl.apache.org/bugs/
Mail list info: http://perl.apache.org/maillist/modperl.html
List etiquette: http://perl.apache.org/maillist/email-etiquette.html


Re: AIM/mp2 Apache::compat bug?

Posted by Geoffrey Young <ge...@modperlcookbook.org>.

Malcolm J Harwood wrote:
> On Tuesday 23 November 2004 11:56 am, Stas Bekman wrote:
> 
> 
>>>>with mp2 you need to update the stat info yourself each time you update
>>>>$r->filename. something like this:
>>>>
>>>> $r->filename($newfile);
>>>> $r->finfo(APR::Finfo::stat($newfile, APR::FINFO_NORM, $r->pool));
> 
> 
>>I've updated the docs to mention that:
>>http://perl.apache.org/docs/2.0/api/Apache/RequestRec.html#C_filename_
> 
> 
> Out of curiosity, what was the reason for the change? I would have thought it 
> is much more prone to user error (people not knowing or forgetting to update 
> the states). Are there cases where you'd change the filename but not need to 
> restat it?

if you change $r->filename in a PerlTransHandler then the default
map-to-storage handler will do the stat for you.  so, you should only need
the additional stat call after map-to-storage runs (such as from a
PerlFixupHandler).

--Geoff

-- 
Report problems: http://perl.apache.org/bugs/
Mail list info: http://perl.apache.org/maillist/modperl.html
List etiquette: http://perl.apache.org/maillist/email-etiquette.html


Re: AIM/mp2 Apache::compat bug?

Posted by Malcolm J Harwood <mj...@liminalflux.net>.
On Tuesday 23 November 2004 11:56 am, Stas Bekman wrote:

> >> with mp2 you need to update the stat info yourself each time you update
> >> $r->filename. something like this:
> >>
> >>  $r->filename($newfile);
> >>  $r->finfo(APR::Finfo::stat($newfile, APR::FINFO_NORM, $r->pool));

> I've updated the docs to mention that:
> http://perl.apache.org/docs/2.0/api/Apache/RequestRec.html#C_filename_

Out of curiosity, what was the reason for the change? I would have thought it 
is much more prone to user error (people not knowing or forgetting to update 
the states). Are there cases where you'd change the filename but not need to 
restat it?


-- 
"And what are you?" "Alive. Everything else is negotiable."
- Sheridan and Franklin, Babylon 5

-- 
Report problems: http://perl.apache.org/bugs/
Mail list info: http://perl.apache.org/maillist/modperl.html
List etiquette: http://perl.apache.org/maillist/email-etiquette.html


Re: AIM/mp2 Apache::compat bug?

Posted by Stas Bekman <st...@stason.org>.
RobertCZ wrote:
[...]
>> with mp2 you need to update the stat info yourself each time you update
>> $r->filename. something like this:
>>
>>  $r->filename($newfile);
>>  $r->finfo(APR::Finfo::stat($newfile, APR::FINFO_NORM, $r->pool));
>>  
>>
> 
> Yes, you're answering exactly the question I was trying to ask ;-) Thank 
> a lot.

I've updated the docs to mention that:
http://perl.apache.org/docs/2.0/api/Apache/RequestRec.html#C_filename_

-- 
__________________________________________________________________
Stas Bekman            JAm_pH ------> Just Another mod_perl Hacker
http://stason.org/     mod_perl Guide ---> http://perl.apache.org
mailto:stas@stason.org http://use.perl.org http://apacheweek.com
http://modperlbook.org http://apache.org   http://ticketmaster.com

-- 
Report problems: http://perl.apache.org/bugs/
Mail list info: http://perl.apache.org/maillist/modperl.html
List etiquette: http://perl.apache.org/maillist/email-etiquette.html


Re: AIM/mp2 Apache::compat bug?

Posted by Stas Bekman <st...@stason.org>.
RobertCZ wrote:
[...]
>> with mp2 you need to update the stat info yourself each time you update
>> $r->filename. something like this:
>>
>>  $r->filename($newfile);
>>  $r->finfo(APR::Finfo::stat($newfile, APR::FINFO_NORM, $r->pool));
>>  
>>
> 
> Yes, you're answering exactly the question I was trying to ask ;-) Thank 
> a lot.

I've updated the docs to mention that:
http://perl.apache.org/docs/2.0/api/Apache/RequestRec.html#C_filename_

-- 
__________________________________________________________________
Stas Bekman            JAm_pH ------> Just Another mod_perl Hacker
http://stason.org/     mod_perl Guide ---> http://perl.apache.org
mailto:stas@stason.org http://use.perl.org http://apacheweek.com
http://modperlbook.org http://apache.org   http://ticketmaster.com

---------------------------------------------------------------------
To unsubscribe, e-mail: embperl-unsubscribe@perl.apache.org
For additional commands, e-mail: embperl-help@perl.apache.org


Re: AIM/mp2 Apache::compat bug?

Posted by RobertCZ <ro...@robert.cz>.
Geoffrey Young wrote:

>RobertCZ wrote:
>  
>
>>RobertCZ wrote:
>>    
>>
>>>I'm playing with Apache::ImageMagick under mod_perl 2 and
>>>Apache::compat (mainly because AIM needs Apache::File which is not
>>>supported under mp2). AIM/mp2 returns the correct modified file but
>>>with wrong file size (size of the original file, not the modified
>>>one). It does work under mod_perl 1, could this be Apache::compat bug?
>>>If yes, any idea how it could  fixed? 
>>>      
>>>
>>Well, now I got rid of Apache::compat (changed Apache::File to
>>FileHandle/File::Temp) and I got the same problem, so Apache::compat is
>>innocent Could it be that PerlFixupHandler in mp2 needs to set length
>>manually when it's different from the original file while mp1
>>recalculates it automaticaly? Thanks for your help.
>>    
>>
>
>well, you message is sufficiently vague since I don't have the
>Apache::ImageMagick code handy :)
>
>but I suspect that you mean that the module sets $r->filename and with mp1
>the new filename's stat info is updated, but with mp2 it is not?  if so,
>yes, this is proper - mp1 did magic behind the scenes for you.
>
>with mp2 you need to update the stat info yourself each time you update
>$r->filename. something like this:
>
>  $r->filename($newfile);
>  $r->finfo(APR::Finfo::stat($newfile, APR::FINFO_NORM, $r->pool));
>  
>

Yes, you're answering exactly the question I was trying to ask ;-) Thank 
a lot.

- Robert

Re: AIM/mp2 Apache::compat bug?

Posted by RobertCZ <ro...@robert.cz>.
Geoffrey Young wrote:

>RobertCZ wrote:
>  
>
>>RobertCZ wrote:
>>    
>>
>>>I'm playing with Apache::ImageMagick under mod_perl 2 and
>>>Apache::compat (mainly because AIM needs Apache::File which is not
>>>supported under mp2). AIM/mp2 returns the correct modified file but
>>>with wrong file size (size of the original file, not the modified
>>>one). It does work under mod_perl 1, could this be Apache::compat bug?
>>>If yes, any idea how it could  fixed? 
>>>      
>>>
>>Well, now I got rid of Apache::compat (changed Apache::File to
>>FileHandle/File::Temp) and I got the same problem, so Apache::compat is
>>innocent Could it be that PerlFixupHandler in mp2 needs to set length
>>manually when it's different from the original file while mp1
>>recalculates it automaticaly? Thanks for your help.
>>    
>>
>
>well, you message is sufficiently vague since I don't have the
>Apache::ImageMagick code handy :)
>
>but I suspect that you mean that the module sets $r->filename and with mp1
>the new filename's stat info is updated, but with mp2 it is not?  if so,
>yes, this is proper - mp1 did magic behind the scenes for you.
>
>with mp2 you need to update the stat info yourself each time you update
>$r->filename. something like this:
>
>  $r->filename($newfile);
>  $r->finfo(APR::Finfo::stat($newfile, APR::FINFO_NORM, $r->pool));
>  
>

Yes, you're answering exactly the question I was trying to ask ;-) Thank 
a lot.

- Robert

Re: AIM/mp2 Apache::compat bug?

Posted by Geoffrey Young <ge...@modperlcookbook.org>.

RobertCZ wrote:
> RobertCZ wrote:
> 
>> I'm playing with Apache::ImageMagick under mod_perl 2 and
>> Apache::compat (mainly because AIM needs Apache::File which is not
>> supported under mp2). AIM/mp2 returns the correct modified file but
>> with wrong file size (size of the original file, not the modified
>> one). It does work under mod_perl 1, could this be Apache::compat bug?
>> If yes, any idea how it could  fixed? 
> 
> 
> Well, now I got rid of Apache::compat (changed Apache::File to
> FileHandle/File::Temp) and I got the same problem, so Apache::compat is
> innocent Could it be that PerlFixupHandler in mp2 needs to set length
> manually when it's different from the original file while mp1
> recalculates it automaticaly? Thanks for your help.

well, you message is sufficiently vague since I don't have the
Apache::ImageMagick code handy :)

but I suspect that you mean that the module sets $r->filename and with mp1
the new filename's stat info is updated, but with mp2 it is not?  if so,
yes, this is proper - mp1 did magic behind the scenes for you.

with mp2 you need to update the stat info yourself each time you update
$r->filename. something like this:

  $r->filename($newfile);
  $r->finfo(APR::Finfo::stat($newfile, APR::FINFO_NORM, $r->pool));

HTH

--Geoff

-- 
Report problems: http://perl.apache.org/bugs/
Mail list info: http://perl.apache.org/maillist/modperl.html
List etiquette: http://perl.apache.org/maillist/email-etiquette.html


Re: AIM/mp2 Apache::compat bug?

Posted by Geoffrey Young <ge...@modperlcookbook.org>.

RobertCZ wrote:
> RobertCZ wrote:
> 
>> I'm playing with Apache::ImageMagick under mod_perl 2 and
>> Apache::compat (mainly because AIM needs Apache::File which is not
>> supported under mp2). AIM/mp2 returns the correct modified file but
>> with wrong file size (size of the original file, not the modified
>> one). It does work under mod_perl 1, could this be Apache::compat bug?
>> If yes, any idea how it could  fixed? 
> 
> 
> Well, now I got rid of Apache::compat (changed Apache::File to
> FileHandle/File::Temp) and I got the same problem, so Apache::compat is
> innocent Could it be that PerlFixupHandler in mp2 needs to set length
> manually when it's different from the original file while mp1
> recalculates it automaticaly? Thanks for your help.

well, you message is sufficiently vague since I don't have the
Apache::ImageMagick code handy :)

but I suspect that you mean that the module sets $r->filename and with mp1
the new filename's stat info is updated, but with mp2 it is not?  if so,
yes, this is proper - mp1 did magic behind the scenes for you.

with mp2 you need to update the stat info yourself each time you update
$r->filename. something like this:

  $r->filename($newfile);
  $r->finfo(APR::Finfo::stat($newfile, APR::FINFO_NORM, $r->pool));

HTH

--Geoff

---------------------------------------------------------------------
To unsubscribe, e-mail: embperl-unsubscribe@perl.apache.org
For additional commands, e-mail: embperl-help@perl.apache.org


Re: AIM/mp2 Apache::compat bug?

Posted by RobertCZ <ro...@robert.cz>.
RobertCZ wrote:

> I'm playing with Apache::ImageMagick under mod_perl 2 and 
> Apache::compat (mainly because AIM needs Apache::File which is not 
> supported under mp2). AIM/mp2 returns the correct modified file but 
> with wrong file size (size of the original file, not the modified 
> one). It does work under mod_perl 1, could this be Apache::compat bug? 
> If yes, any idea how it could  fixed? 

Well, now I got rid of Apache::compat (changed Apache::File to 
FileHandle/File::Temp) and I got the same problem, so Apache::compat is 
innocent Could it be that PerlFixupHandler in mp2 needs to set length 
manually when it's different from the original file while mp1 
recalculates it automaticaly? Thanks for your help.

- Robert



---------------------------------------------------------------------
To unsubscribe, e-mail: embperl-unsubscribe@perl.apache.org
For additional commands, e-mail: embperl-help@perl.apache.org


Re: AIM/mp2 Apache::compat bug?

Posted by RobertCZ <ro...@robert.cz>.
RobertCZ wrote:

> I'm playing with Apache::ImageMagick under mod_perl 2 and 
> Apache::compat (mainly because AIM needs Apache::File which is not 
> supported under mp2). AIM/mp2 returns the correct modified file but 
> with wrong file size (size of the original file, not the modified 
> one). It does work under mod_perl 1, could this be Apache::compat bug? 
> If yes, any idea how it could  fixed? 

Well, now I got rid of Apache::compat (changed Apache::File to 
FileHandle/File::Temp) and I got the same problem, so Apache::compat is 
innocent Could it be that PerlFixupHandler in mp2 needs to set length 
manually when it's different from the original file while mp1 
recalculates it automaticaly? Thanks for your help.

- Robert



-- 
Report problems: http://perl.apache.org/bugs/
Mail list info: http://perl.apache.org/maillist/modperl.html
List etiquette: http://perl.apache.org/maillist/email-etiquette.html