Changeset dfab1e


Ignore:
Timestamp:
03/09/08 17:14:01 (4 years ago)
Author:
Tomash Brechko <tomash.brechko@…>
Branches:
master, ketama-compat
Children:
3760ea
Parents:
2986b7
git-author:
Tomash Brechko <tomash.brechko@…> (03/09/08 17:14:01)
git-committer:
Tomash Brechko <tomash.brechko@…> (03/09/08 17:14:01)
Message:

In the case of collision, add new servers to the end of equal run.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/dispatch_key.c

    r2986b7 rdfab1e  
    186186      if (! array_empty(state->buckets)) 
    187187        { 
     188          struct continuum_point *end = 
     189            array_end(state->buckets, struct continuum_point); 
     190 
    188191          p = dispatch_find_bucket(state, point); 
    189192 
     
    192195              && point > p->point) 
    193196            { 
    194               p = array_end(state->buckets, struct continuum_point); 
     197              p = end; 
    195198            } 
    196199          else 
    197200            { 
    198               if (point == p->point) 
    199                 { 
    200                   /* 
    201                     Even if there's a server for the same point 
    202                     already, we have to add ours, because the first 
    203                     one may be removed later.  But we add ours after 
    204                     the first server for not to change key 
    205                     distribution. 
    206                   */ 
    207                   ++p; 
    208                 } 
     201              /* 
     202                Even if there's a server for the same point already, 
     203                we have to add ours, because the first one may be 
     204                removed later.  But we add ours after the old servers 
     205                for not to change key distribution. 
     206              */ 
     207              while (p != end && p->point == point) 
     208                ++p; 
    209209 
    210210              /* Move the tail one position forward.  */ 
    211               memmove(p + 1, p, 
    212                       ((array_end(state->buckets, struct continuum_point) - p) 
    213                        * sizeof(*p))); 
     211              if (p != end) 
     212                memmove(p + 1, p, (end - p) * sizeof(*p)); 
    214213            } 
    215214        } 
Note: See TracChangeset for help on using the changeset viewer.