Interface Patch

Brian Aker brian at
Mon Feb 4 15:51:47 UTC 2008


On Feb 4, 2008, at 1:49 AM, Tomash Brechko wrote:

> On Mon, Feb 04, 2008 at 00:44:49 -0800, Brian Aker wrote:
>> This do { } while loop won't close sfd_list[0] (and the first if()
> would also skip over the just created socket too).  Use the loop from
> my mail ;).

Your loop does not work:
                   while (sfd_ptr != sfd_list) {

You incremented first to a pointer that may walk off the end of the  
array. You then decremented back to the pointer that is current (which  
is not set).
Then you loop to close and never touch the final member of the array.

In my haste I left the increment wrong as well:
                     do {
                     } while (sfd_ptr != sfd_list);

This way you move past the current pointer you are on (since it is not  
valid) and then jump to the next.
You close() and move on. The final pointer will be caught and then  
when you hit the while on the last pointer (after you have closed it),  
you will exit.

Brian "Krow" Aker, brian at
Seattle, Washington                     <-- Me                <-- Software    <-- Fun
You can't grep a dead tree.

More information about the memcached mailing list