Re: [squid-users] external_acl program...

From: Chris Robertson <crobertson_at_gci.net>
Date: Tue, 19 Aug 2008 12:05:34 -0800

John Doe wrote:
> Hi,
>
> I have a little problem with my external_acl C program.
> Everything works fine with a php version, but my original C version, for some tricky reason, does not...
> Tested both from the console and they seem to behave exactly in the same way...
> I am calling either program with the same syntax:
>
> external_acl_type filter children=8 concurrency=0 ttl=0 negative_ttl=0 %PATH filter
>
> The following in PHP works fine with squid:
>
> while (!feof(STDIN)) {
> $url = fgets(STDIN);
> fwrite(STDERR, 'filter: url='.$url."\n");
> fwrite(STDOUT, 'OK user=allowed'."\n");
> fwrite(STDERR, 'filter: end of while...'."\n");
> }
>
> The following in C does not work well with squid:
>
> while (fgets(url, sizeof(url), stdin)) {
> // let's ignore the '\n' at the end of url, it only appear in the logs anyway...
> fprintf(stderr, "filter: url=%s\n", url);
> printf("OK user=allowed\n");
> fprintf(stderr, "filter: end of while...\n");
> }
>
> With the C version, if I load a test page with 3 images going through squid, I will have the following in the squid_cache.log:
>
> filter: url=/path/to/img1.gif
> filter: end of while...
> filter: url=/path/to/img2.gif
> filter: end of while...
> filter: url=/path/to/img3.gif
> filter: end of while...
>
> and then squid will just wait (for the 3 instances of my program?), blocking everything...
> When I stop squid, I get 3 messages like:
>
> WARNING: Closing client 192.168.16.23 connection due to lifetime timeout
> 2008/08/19 17:05:18| http://localhost/path/to/img1.gif
>
> Any idea what is wrong with my C code...?
>
> Thx,
> JD
>

Sounds like you are having problems with output buffering. Try adding...

fflush(stdout);

...after your fprintf statement.

Chris
Received on Tue Aug 19 2008 - 20:05:44 MDT

This archive was generated by hypermail 2.2.0 : Wed Aug 20 2008 - 12:00:04 MDT