Terry-Mao / gopush-cluster

Golang push server cluster
GNU General Public License v3.0
2.08k stars 558 forks source link

user channel list 求余的问题 #56

Open SongCF opened 7 years ago

SongCF commented 7 years ago
//func (l *ChannelList) Bucket(key string) *ChannelBucket 
idx := uint(h.Sum32()) & uint(Conf.ChannelBucket-1)  //其中 ChannelBucket = runtime.NumCPU()

只有当x=2^n(n为自然数)时,a % x = a & (x - 1 )才成立, 又服务器cpu至少我见过有10核12核的

那么这里就计算出的idx会有问题吧

Terry-Mao commented 7 years ago

我印象中,在配置文件里面有强制他2^n