CAS is broken

Dustin Sallings dustin at spy.net
Thu Nov 15 17:28:34 UTC 2007


   All that really matters is that it's unique for each subsequent  
call (for a while).  If you just gut the body and make it a static  
declaration and an increment, it'll be just as good even uninitialized.

   The additional cyclomatic complexity was just to make things more  
explicit.

   Initially, I wanted to guarantee it never returned 0, but there's  
not a terribly good reason for that.

-- 
Dustin Sallings (mobile)

On Nov 15, 2007, at 9:13, dormando <dormando at rydia.net> wrote:

>> This test against MAX_CAS_ID is not needed: C standard _guarantees_
>> that ++ for unsigned type will wraparound to zero automagically.  And
>> this condition won't be ever met anyway, so the check is a bit of a
>> waste (unless you have some reasons not to use full 64 bit range that
>> I'm failing to see, of course).
>>> @@ -697,11 +698,15 @@ static void complete_nread(conn *c) {
>> ...
>>> +      else if(ret == 3)
>>> +          out_string(c, "NOT FOUND");
>> Should be "NOT_FOUND" (with underscore).  This typo was present in  
>> the
>> original code, and was accidentally copied here.
>
> Both fixed in r636, plus explicitly initialized the cas_id to zero  
> for portability. :)
>
> -Dormando
>
>


More information about the memcached mailing list