[squid-users] Receiving blank input in External ACL

Alberto Perez alberto2perez at gmail.com
Wed Feb 11 15:43:01 UTC 2015


Hi to all  and thanks for the time given to read and reply these emails


I am having an strange issue with my external ACL, ocassionally im
getting blank inputs from squid to by proccessed by the external ACL,
for those cases I am returning ERR but squid is complainting showing
in cache.log errors like

2015/02/11 10:01:36| helperHandleRead: unexpected read from
session_active_def #Hlpr5, 4 bytes 'ERR
'

My question is, what should I return in those cases? its normal to
recieve those blanks? how to avoid them if possible?

Im worried about this detail because related to this events (only some
times) squid stop serving to client who fired the event, client has to
change IP to continue surfing.

Here is the definition of the external ACL, its supposed to receive IP

# Set up the normal session helper.
external_acl_type session_active_def concurrency=1 children-max=15
children-startup=12  ipv4 ttl=3 negative_ttl=1 %SRC
/etc/squid3/captive/sessionHelper.php

And here the code

#!/usr/bin/php
<?php
error_reporting(0);
$meminstance = new Memcache();
$meminstance->pconnect('127.0.0.1', 11211);
ini_set("memory_limit",($memoryLimit=512)."M");
while (!@feof(STDIN)) {
try{

	$line = trim(fgets(STDIN));
	if (!$line) { shell_exec("echo \"SESSION - No client ip error: \"
".$line." - "." - $(date) >> /var/log/squid3/session.log");
fwrite(STDOUT, "ERR\n"); continue;}

	$line = explode(" ", $line);

	$clientip = count($line > 1)?$line[1]:false; //1738

	if (!$clientip) { shell_exec("echo \"SESSION - No client ip error: \"
".$line." - "." - $(date) >> /var/log/squid3/session.log");
fwrite(STDOUT, "ERR\n"); continue;}

	 $username = $meminstance->get($clientip);
	$hasInternet = $username?$meminstance->get("has_internet_$username"):false;
	if ($username && $hasInternet){
			// extend session
 			$meminstance->set($clientip, $username, 0,3600); // extend 10 min
			$meminstance->set("ip_".$username, $clientip, 0, 3600); // 10 min
			$meminstance->set("has_internet_".$username, true, 0, 3600); // 10 min
	                fwrite(STDOUT, "OK user=$username\n");
	}else{
        	fwrite(STDOUT, "ERR\n");
	}
}catch(Exception $e){
        	fwrite(STDOUT, "BH\n");
}
}
exit;
?>



Thanks to all


More information about the squid-users mailing list