PECL memcache extension

Don MacAskill don at smugmug.com
Fri Mar 10 23:15:04 UTC 2006


Brian Moon wrote:
> Don MacAskill wrote:
>>
>> Hi Mikael,
>>
>> I'm getting a segfault when a server fails and I try to set status. 
>> Example code:
>>
>> $memCache = new Memcache();
>>
>> $memCache->addServer("192.168.0.1", "10000", 1, 1, 1, 15, true, 
>> 'memcacheFailCallback');
>> $memCache->add("test", "value");
>>
>> function memcacheFailCallback($Host, $Port) {
>>     global $memCache;
>>     $memCache->setServerParams($Host, $Port, 1, -1, false, 
>> 'memcacheFailCallback');
>> }
> 
> I don't know exactly how that call back works, but it looks like that if 
> $memCache->setServerParams fails, you could have an endless recursion.
> 
> I could be wrong.
> 

I don't think so, since if I have trigger_error() calls in there, I only 
see one call before it segfaults, not lots like it's recursing.

Regardless, this code also segfaults:


$memCache = new Memcache();

$memCache->addServer("192.168.0.1", "10000", 1, 1, 1, 15, true, 
'memcacheFailCallback');
$memCache->add("test", "value");

function memcacheFailCallback($Host, $Port) {
	global $memCache;
	if(!$memCache->getServerStatus($Host, $Port)) {
		trigger_error("setting off");
		$memCache->setServerParams($Host, $Port, 1, -1, false, 
'memcacheFailCallback');
	}
}

And it should catch failed servers and not try to set them as failed 
again, if the callback worked that way.  (Again, it doesn't appear to).

Thanks for mentioning it, though.  I could have easily overlooked that 
possibility.

Don




More information about the memcached mailing list