mirror of
https://github.com/cloudwu/skynet.git
synced 2026-07-24 12:20:41 +00:00
overflow check
This commit is contained in:
@@ -367,6 +367,9 @@ shrstr_expandpage(unsigned int cap) {
|
|||||||
return;
|
return;
|
||||||
unsigned int osz = s->mask + 1;
|
unsigned int osz = s->mask + 1;
|
||||||
unsigned int sz = osz * 2;
|
unsigned int sz = osz * 2;
|
||||||
|
// overflow check
|
||||||
|
if (sz == 0)
|
||||||
|
return;
|
||||||
while (sz < cap)
|
while (sz < cap)
|
||||||
sz = sz * 2;
|
sz = sz * 2;
|
||||||
struct shrmap_slot * newpage = shrstr_newpage(sz);
|
struct shrmap_slot * newpage = shrstr_newpage(sz);
|
||||||
@@ -655,11 +658,10 @@ luaS_shrinfo(lua_State *L) {
|
|||||||
lua_pushinteger(L, total.len); // longest
|
lua_pushinteger(L, total.len); // longest
|
||||||
lua_pushinteger(L, SSM.n); // space
|
lua_pushinteger(L, SSM.n); // space
|
||||||
lua_pushinteger(L, slots); // slots
|
lua_pushinteger(L, slots); // slots
|
||||||
lua_pushnumber(L, v.mean); // average
|
|
||||||
if (v.count > 1) {
|
if (v.count > 1) {
|
||||||
lua_pushnumber(L, v.m2 / v.count); // variance
|
lua_pushnumber(L, v.m2 / v.count); // variance
|
||||||
} else {
|
} else {
|
||||||
lua_pushnumber(L, 0); // variance
|
lua_pushnumber(L, 0); // variance
|
||||||
}
|
}
|
||||||
return 7;
|
return 6;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -336,8 +336,8 @@ function COMMAND.cmem()
|
|||||||
end
|
end
|
||||||
|
|
||||||
function COMMAND.shrtbl()
|
function COMMAND.shrtbl()
|
||||||
local n, total, longest, space, slots, avg, variance = memory.ssinfo()
|
local n, total, longest, space, slots, variance = memory.ssinfo()
|
||||||
return { n = n, total = total, longest = longest, space = space, slots = slots, average = avg, variace = variance }
|
return { n = n, total = total, longest = longest, space = space, slots = slots, average = n / slots, variace = variance }
|
||||||
end
|
end
|
||||||
|
|
||||||
function COMMAND.ping(address)
|
function COMMAND.ping(address)
|
||||||
|
|||||||
Reference in New Issue
Block a user