Skip to content

Commit

Permalink
error check
Browse files Browse the repository at this point in the history
  • Loading branch information
sniper00 committed Aug 13, 2023
1 parent 14e4c62 commit acaf2ab
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
2 changes: 1 addition & 1 deletion lualib/moon/http/client.lua
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ end
local function response_handler(fd, method)
local data, err = socket.read(fd, "\r\n\r\n")
if not data then
return { socket_error = err }
return { error = err }
end

--print("raw data",data)
Expand Down
8 changes: 5 additions & 3 deletions service/cluster.lua
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ local function cluster_service()
local strfmt = string.format

local unpack_one = seri.unpack_one
local queryservice = moon.queryservice

local redirect = moon.redirect

Expand Down Expand Up @@ -171,7 +170,6 @@ local function cluster_service()
assert(c.host and c.port, "require host and port")

local listenfd = socket.listen(c.host, c.port,moon.PTYPE_SOCKET_MOON)
assert(listenfd>0, strfmt("cluster listen %s:%s failed for node=%s", c.host, c.port, NODE))
socket.start(listenfd)
print(strfmt("cluster listen %s:%d", c.host, c.port))
setmetatable(clusters, {__gc=function()
Expand Down Expand Up @@ -278,7 +276,11 @@ local function cluster_service()
fn(msg)
end
else
moon.error(moon.name, "recv unknown cmd "..tostring(cmd))
if session == 0 then
moon.error(moon.name, "recv unknown cmd "..tostring(cmd))
else
moon.response("lua", sender, session, false, moon.name.." recv unknown cmd "..tostring(cmd))
end
end
end, m)
end)
Expand Down

0 comments on commit acaf2ab

Please sign in to comment.