httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Stas Bekman <s...@stason.org>
Subject Re: core dump in ap_send_fd
Date Fri, 21 Dec 2001 06:14:38 GMT
Cliff Woolley wrote:

> [moving this to dev@httpd since it's an httpd issue]
> 
> 
> On Fri, 21 Dec 2001, Stas Bekman wrote:
> 
> 
>>ap_send_fd expects the length of the input to send.
>>
>>First of all is there a way not to specify the length? I've a fd (can be
>>a pipe to a process), and I've no way to figure out the length of the
>>output. How APR can handle this? This breaks the compatibility with
>>send_fd from httpd-1.3.x.
>>
> 
> You don't want to send a pipe with ap_send_fd() in Apache 2.0, as it would
> put the pipe in a file bucket, which is wrong.  


Agreed. But it breaks the backwards compatibility with ap_send_fd from 
1.3.x. I am porting ap_send_fd for mod_perl 2.0 and it has to stay the same.

> Maybe we should add an
> ap_send_pipe(), or maybe we should change the ap_send_fd() API to accept
> -1 as a magic length and to recognize it as meaning the thing is a pipe
> not a file. 


Yup, that's how it was in 1.3.x's version.
which will work for files as well. If you can do that, the problem is 
solved.

> In the meanwhile, you need to use the buckets directly.
> It's only four lines of code as opposed to one.
> 
> apr_bucket_brigade *bb = apr_brigade_create(r->pool);
> apr_bucket *b = apr_bucket_pipe_create(thepipe);
> APR_BRIGADE_INSERT_TAIL(bb, b);
> ap_pass_brigade(bb);


can I use this for sending an opened file as well? given that I've a fd 
already opened from Perl. I use ap_os_file_put to convert it into 
apr_file_t.

Does using a ap_send_pipe (from above) instead of a ap_send_fd have any 
performance implications? Other than the fact that the fast native 
sendfile won't be used for sending real files?


>>Second, I've found something that appears to be a bug. If I tell
>>ap_send_fd to send one char more than the size of the file that I try to
>>send, it asserts and dumps core, the latter probably is bad.
>>
> 
> Um, why would you ever do that and expect it to work?  I mean, I guess we
> could theoretically check the length you pass in against the length of the
> file, but that goes against the
> we-expect-the-caller-to-pass-us-sane-arguments mentality that we typically
> maintain around here.

Well, I don't think it is normal to dump core if some of the arguments is not proper, 

especially in this case where it's just the count that can be wrong. But that bothers me less,


if you think it's fine to core dump, rather than cleanly exit with an error message :)


Thanks Cliff,
_____________________________________________________________________
Stas Bekman             JAm_pH      --   Just Another mod_perl Hacker
http://stason.org/      mod_perl Guide   http://perl.apache.org/guide
mailto:stas@stason.org  http://ticketmaster.com http://apacheweek.com
http://singlesheaven.com http://perl.apache.org http://perlmonth.com/


Mime
View raw message