apr-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Joe Orton <jor...@redhat.com>
Subject Re: how to make apr_bucket_read() read only as much as I need?
Date Fri, 19 Aug 2005 08:21:16 GMT
On Fri, Aug 19, 2005 at 12:07:37AM -0700, Stas Bekman wrote:
> Joe Orton wrote:
> >On Thu, Aug 18, 2005 at 06:25:23PM -0700, Stas Bekman wrote:
> >
> >>when reading from most bucket types you want to read all the data. This 
> >>is not the case with socket buckets, since the amount of data on the 
> >>socket can be anything. At the moment the code hardcodes 8K of data is to 
> >>be read. What do I do if I want to control how much data is read from the 
> >>socket?
> >
> >
> >Why do you need to do that?  You shouldn't really care.
> 
> We do care, because we write a throttling filter for the smtp module, so 
> we want to slow down the spammers, reading 8K defeats the purpose of the 
> throttling filter (we read like 32B and then sleep), since most spam 
> messages will be consumed by the server side. that filter will be 
> available on CPAN once completed.

Hmmm, tricky.  I would suspect it would be better to achieve this using 
socket options, though I'm not sure how feasible that is; e.g. try 
setting SO_RCVBUF to 32.  You really want to prevent the TCP stack from 
buffering and ACKing the data as well if you want to throttle the sender 
from the word go.

Otherwise, I guess what you could do here is implement a new bucket 
type, which is a clone of SOCKET, except it stores a length parameter 
which is used in the place of APR_BUCKET_BUFF_SIZE on each ->read() 
invocation; allowing the caller to change the length as necessary using 
an accessor function.

You can't change the apr_bucket_read() interface itself so I'm not sure 
exactly what you were trying to do with the changes you mention.

joe

Mime
View raw message