Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into self_login
Browse files Browse the repository at this point in the history
# Conflicts:
#	server/robot/accord_mgr.lua
#	server/robot/dao/accord_dao.lua
#	server/robot/msg_mgr.lua
  • Loading branch information
wangpeng committed Oct 9, 2023
2 parents f6be421 + b342a16 commit afdb13d
Show file tree
Hide file tree
Showing 9 changed files with 23 additions and 19 deletions.
4 changes: 4 additions & 0 deletions extend/lbson/src/bson.h
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,10 @@ namespace lbson {
if (!lua_isinteger(L, -2)) {
return bson_type::BSON_DOCUMENT;
}
size_t key = lua_tointeger(L, -2);
if (key <= 0 || key > raw_len) {
return bson_type::BSON_DOCUMENT;
}
cur_len++;
lua_pop(L, 1);
}
Expand Down
8 changes: 0 additions & 8 deletions extend/lbson/src/lbson.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,6 @@ namespace lbson {
static int decode(lua_State* L) {
return thread_bson.decode(L);
}
static slice* encode_slice(lua_State* L) {
return thread_bson.encode_slice(L);
}
static int decode_slice(lua_State* L, slice* slice) {
return thread_bson.decode_slice(L, slice);
}
static bson_value* int32(int32_t value) {
return new bson_value(bson_type::BSON_INT64, value);
}
Expand Down Expand Up @@ -50,8 +44,6 @@ namespace lbson {
auto llbson = kit_state.new_table();
llbson.set_function("encode", encode);
llbson.set_function("decode", decode);
llbson.set_function("encode_slice", encode_slice);
llbson.set_function("decode_slice", decode_slice);
llbson.set_function("mongocodec", mongo_codec);
llbson.set_function("timestamp", timestamp);
llbson.set_function("int32", int32);
Expand Down
3 changes: 2 additions & 1 deletion extend/lcodec/src/websocket.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ namespace lcodec {
uint8_t masklen = (((*payload) & 0x80) == 0x80) ? 4 : 0;
uint8_t payloadlen = (*payload) & 0x7f;
if (payloadlen < 0x7e) {
return masklen + payloadlen + sizeof(uint16_t);
m_packet_len = masklen + payloadlen + sizeof(uint16_t);
return m_packet_len;
}
size_t* length = (size_t*)m_slice->peek((payloadlen == 0x7f) ? 8 : 2, sizeof(uint16_t));
if (!length) return 0;
Expand Down
4 changes: 4 additions & 0 deletions extend/ljson/src/ljson.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,10 @@ namespace ljson {
if (!lua_isinteger(L, -2)) {
return false;
}
size_t key = lua_tointeger(L, -2);
if (key <= 0 || key > raw_len) {
return false;
}
lua_pop(L, 1);
cur_len++;
}
Expand Down
4 changes: 4 additions & 0 deletions extend/luakit/include/lua_codec.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,10 @@ namespace luakit {
if (!lua_isinteger(L, -2)) {
return false;
}
size_t key = lua_tointeger(L, -2);
if (key <= 0 || key > raw_len) {
return false;
}
cur_len++;
lua_pop(L, 1);
}
Expand Down
5 changes: 4 additions & 1 deletion script/driver/websocket.lua
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ local qxpcall = quanta.xpcall

local proto_text = luabus.eproto_type.text

local event_mgr = quanta.get("event_mgr")
local socket_mgr = quanta.get("socket_mgr")
local thread_mgr = quanta.get("thread_mgr")

Expand Down Expand Up @@ -152,7 +153,9 @@ function WebSocket:on_handshake(session, token, url, params, headers, body)
self.session = session
self:send_data(101, cbheaders, "")
self.host:on_socket_accept(self, token)
session.set_codec(self.wcodec)
event_mgr:fire_frame(function()
session.set_codec(self.wcodec)
end)
return true
end

Expand Down
6 changes: 2 additions & 4 deletions server/robot/accord_mgr.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@
local log_warn = logger.warn
local log_debug = logger.debug
local jdecode = json.decode
local jencode = json.encode
local json_pretty = json.pretty
local tinsert = table.insert

local HttpServer = import("network/http_server.lua")

Expand Down Expand Up @@ -202,9 +200,9 @@ function AccordMgr:on_case_group_del(url, body)
if not group then
return { code = 0 }
end
for id,accord in pairs(self.accord_list) do
for aid, accord in pairs(self.accord_list) do
if group.name == accord.casegroup then
accord_dao:delete("accord_conf", id)
accord_dao:delete("accord_conf", aid)
end
end
self.case_group[id] = nil
Expand Down
6 changes: 3 additions & 3 deletions server/robot/dao/accord_dao.lua
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ end

-- 插入数据
function AccordDao:insert(document, data)
local code, res = mongo_mgr:insert(1, mrandom(), document, data)
local code = mongo_mgr:insert(1, mrandom(), document, data)
if code ~= SUCCESS then
log_debug("[AccordDao][insert] document:{} code:{}", document, code)
return false
Expand All @@ -33,7 +33,7 @@ end
-- 更新数据
function AccordDao:update(document, data)
local udata = { ["$set"] = data }
local code, res = mongo_mgr:update(1, mrandom(), document, udata, { id = data.id })
local code = mongo_mgr:update(1, mrandom(), document, udata, { id = data.id })
if code ~= SUCCESS then
log_debug("[AccordDao][update] document:{} code:{}", document, code)
return false
Expand All @@ -43,7 +43,7 @@ end

-- 删除数据
function AccordDao:delete(document, id)
local code, res = mongo_mgr:delete(1, mrandom(), document, {id=id})
local code = mongo_mgr:delete(1, mrandom(), document, {id=id})
if code ~= SUCCESS then
log_debug("[AccordDao][delete] document:{} code:{}", document, code)
return false
Expand Down
2 changes: 0 additions & 2 deletions server/robot/msg_mgr.lua
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
-- robot_mgr.lua

local log_err = logger.err
local log_debug = logger.debug
local pb_enum_id = protobuf.enum
local supper = string.upper
local tunpack = table.unpack
Expand Down

0 comments on commit afdb13d

Please sign in to comment.