Changeset aedaaa


Ignore:
Timestamp:
02/01/09 15:38:20 (3 years ago)
Author:
Tomash Brechko <tomash.brechko@…>
Branches:
master-v0.7, master-v0.6, memcached_hash, upstream_count_limit
Children:
6c857c, fb0da1, f54237
Parents:
321c4d
git-author:
Tomash Brechko <tomash.brechko@…> (02/01/09 15:38:20)
git-committer:
Tomash Brechko <tomash.brechko@…> (02/01/09 15:38:20)
Message:

Better distribution of ketama points.

Feed previous point instead of sequential index.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • memcached_hash/ngx_http_upstream_memcached_hash_module.c

    r321c4d raedaaa  
    344344          u_char *host, *port; 
    345345          size_t len, port_len = 0; 
    346           unsigned int crc32, count, j; 
     346          unsigned int crc32, point, count, j; 
    347347 
    348348          host = server[i].name.data; 
     
    372372          ngx_crc32_update(&crc32, (u_char *) &delim, 1); 
    373373          ngx_crc32_update(&crc32, port, port_len); 
     374          point = 0; 
    374375 
    375376          count = (memd->ketama_points * server[i].weight 
     
    378379            { 
    379380              u_char buf[4]; 
    380               unsigned int point = crc32, bucket; 
     381              unsigned int new_point = crc32, bucket; 
    381382 
    382383              /* 
     
    384385                hardcode size of int as 4 8-bit bytes. 
    385386              */ 
    386               buf[0] = j & 0xff; 
    387               buf[1] = (j >> 8) & 0xff; 
    388               buf[2] = (j >> 16) & 0xff; 
    389               buf[3] = (j >> 24) & 0xff; 
    390  
    391               ngx_crc32_update(&point, buf, 4); 
    392               ngx_crc32_final(point); 
     387              buf[0] = point & 0xff; 
     388              buf[1] = (point >> 8) & 0xff; 
     389              buf[2] = (point >> 16) & 0xff; 
     390              buf[3] = (point >> 24) & 0xff; 
     391 
     392              ngx_crc32_update(&new_point, buf, 4); 
     393              ngx_crc32_final(new_point); 
     394              point = new_point; 
    393395 
    394396              if (memd->buckets_count > 0) 
Note: See TracChangeset for help on using the changeset viewer.