Interface Patch

Tomash Brechko tomash.brechko at gmail.com
Mon Feb 4 16:12:00 UTC 2008


On Mon, Feb 04, 2008 at 07:51:47 -0800, Brian Aker wrote:
> Your loop does not work:
>                   ++sfd_ptr;
>                   while (sfd_ptr != sfd_list) {
>                       --sfd_ptr;
>                       close(*sfd_ptr);
>                   }
> 
> 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).

Yep, for some reason I thought the whole thing begins with

    *sfd_ptr = socket();

This was my mistake.  For your case you'd leave out the first
increment:

                    while (sfd_ptr != sfd_list) {
                        --sfd_ptr;
                        close(*sfd_ptr);
                    }


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

As you don't know whether you are on the first element still, the
whole piece would be

                   if (sfd_ptr != sfd_list) {
                       do {
                           --sfd_ptr;
                           close(*sfd_ptr);
                       } while (sfd_ptr != sfd_list);
                   }

And this would give the 'while' loop above.


So we figured this out.  One more step toward the complete patch
sequence ;).


-- 
   Tomash Brechko


More information about the memcached mailing list