Bug in PHP client?

Russ Garrett rg@tcslon.com
Sun, 21 Sep 2003 17:09:09 +0100


We noticed that pages on our site would hang for no particular reason -
and after extensive debugging (such a pain on PHP), I traced it down to
the memcached client - specifically this part (in _load_items, about
line 1056):

// skip over the extra return or newline
if($line == "\r" || $line == "\n")
      continue;

The problem is this: if the object to be retrieved is of a specific
length, then the last chunk of data retrieved will consist just of the
closing \n from memcached. In this case the if statement will be true,
and it'll continue back to the top of the while loop on line 1006. But
since this was the closing \n, it's the last chunk of data recieved, and
so it'll block for ever on socket_read.

I just commented those two lines out - I can't see why you'd want to
skip over that anyway. But I suggest putting a timeout on that read call
(I assume that's possible - I haven't looked at the PHP raw sockets
interface).

Cheers,

Russ

-- 
Russ Garrett			Last.fm
russ@last.fm			http://www.last.fm