Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

beast_cache_hash会溢出 #33

Closed
wuwei0509 opened this issue Aug 10, 2016 · 4 comments
Closed

beast_cache_hash会溢出 #33

wuwei0509 opened this issue Aug 10, 2016 · 4 comments

Comments

@wuwei0509
Copy link

beast_cache_hash计算使用key->device * 3 + key->inode * 7,且使用int保存并用作index计算。
st_ino的定义是不小于uint:

Data Type: ino_t
This is an unsigned integer type used to represent file serial numbers. (In Unix jargon, these are sometimes called inode numbers.) In the GNU C Library, this type is no narrower than unsigned int.

因此存在溢出可能。
在实际使用docker部署的情况中,出现了st_ino比较大的情况,导致sf。

[10 Aug 17:56:49] ERROR: st_dev: 64769, st_ino: 1611759572, hashval: -1602390577

@liexusong
Copy link
Owner

好的,谢谢

@wuwei0509
Copy link
Author

谢谢fix。貌似直接改uint还是有些问题。% 2147483648 ?

@liexusong
Copy link
Owner

请问是什么意思啊?

@wuwei0509
Copy link
Author

恩,*7还是会超出范围,如果非要在现有算式基础上fix,可以先转换成long long,再取模(% 2147483648)变成int。
当然也可以修改hash算法。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants