Search squid archive

Trouble writing external acl helper

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



I am almost certainly missing something very basic, but I haven't found out
what after searching here and elsewhere, so any help will be greatly
appreciated.

I'm using squid 3.1 on Fedora 12 (64-bit).

I want to write an external acl helper (for fun!) and started with a toy
example written in C which is only going to allow the URL
"http://www.google.com";. It works as I expect when I run it at the command
line (lines are read one-by-one from standard input and a reply of "OK" or
"ERR" appears on standard output), but the output I get from squid says:

    2010/04/14 08:40:23.731| helperOpenServers: Starting 5/5 'toy_helper'
processes
    ...
    2010/04/14 08:40:31.197| WARNING: toy_helper #1 (FD 7) exited
    2010/04/14 08:40:31.197| WARNING: toy_helper #3 (FD 11) exited
    2010/04/14 08:40:31.198| WARNING: toy_helper #2 (FD 9) exited
    2010/04/14 08:40:31.198| WARNING: toy_helper #4 (FD 13) exited
    2010/04/14 08:40:31.198| Too few toy_helper processes are running
    ...
    FATAL: The toy_helper helpers are crashing too rapidly, need help!

In the squid.conf file I've put:

    external_acl_type toy_helper %PATH /tmp/squid-tests/toy_helper
    acl toy external toy_helper

This squid.conf and the toy_helper executable are both in /tmp/squid-tests,
and everything there is world-readable.

Lastly, here is the source for toy_helper:

   1 #include <stdio.h>
   2 #include <string.h>
   3 #define BUFSIZE 8192
   4 
   5 int
   6 main(int argc, char *argv[])
   7 {
   8 
   9   char buf[BUFSIZE];
  10
  11   /* make standard output and input unbuffered */
  12   setvbuf(stdout, NULL, _IONBF, 0);
  13   setvbuf(stdin, NULL, _IONBF, 0);
  14   
  15   /* main loop: read lines from stdin */
  16   while ( fgets(buf, sizeof(buf), stdin) )
  17   {
  18     if ( strcmp("http://www.google.com/\n";, buf) == 0 )
  19       printf("OK\n");
  20     else
  21       printf("ERR\n");
  22   }
  23 
  24   return 0;
  25 }

Thanks in advance for any clues,
John.
-- 
View this message in context: http://n4.nabble.com/Trouble-writing-external-acl-helper-tp1839464p1839464.html
Sent from the Squid - Users mailing list archive at Nabble.com.

[Index of Archives]     [Linux Audio Users]     [Samba]     [Big List of Linux Books]     [Linux USB]     [Yosemite News]

  Powered by Linux