Re: [squid-users] External C program

From: Julien Philibin <julien_at_philibin.fr>
Date: Tue, 28 Apr 2009 10:25:53 -0700

Hi John,
thanks for your reply.

I'll give a shot with your skeleton and see how things are going on ...

On Tue, Apr 28, 2009 at 1:59 AM, John Doe <jdmls_at_yahoo.com> wrote:
>
> From: Julien Philibin <julien_at_philibin.fr>
>> Hi, I've been trying to find a typical external ACL C program skeleton
>> for a while, but I wasn't able to find anything very interesting ...
>> What I would like to do, is to read to different strings and process
>> them in order to allow/disallow access to a website.
>> The thing is, after a while I get two processes that use around 10 Mb
>> of memory and 15% of my CPU ....
>> Also, if I restart squid, I'll get two more processes running and so
>> on, everytime I restart squid ...
>
> Personaly, I use fgets/fflush and I did not see any problem (memory leak, etc) so far...
> Something like:
>
>  #define INPUTSIZE 4096
>  char input[INPUTSIZE];
>  while (fgets(input, sizeof(input), stdin)) {
>    if ((cp=strchr(input, '\n')) == NULL) {
>      fprintf(stderr, "filter: input too big: %s\n", input);
>    } else {
>      *cp = '\0';
>    }
>    ...
>    fflush(stderr);
>    fflush(stdout);
>  }
>
> Do you use any malloc or functions that malloc... and that would need a free?

Yes I do, but I also free them (the memory usage doesn't change). I
also made a mistake, it is not 10Mb but 1 ...

THe only weird thing is that after a restart (of squid), it looks like
squid doesn't have any control anymore on the externals programs and
they (both of external programs) start to use a lot of CPU...

Maybe it has something to do with stdin that was not flushed correctly
and creates an infinite loop or something ...

Anyways, I'll try your way, and I'll let you know!

thanks again for your reply

>
> JD
>
>
>
>
>
Received on Tue Apr 28 2009 - 17:26:16 MDT

This archive was generated by hypermail 2.2.0 : Wed Apr 29 2009 - 12:00:02 MDT