mirror of
https://github.com/cloudwu/skynet.git
synced 2026-07-24 20:23:06 +00:00
minor fix
This commit is contained in:
@@ -151,7 +151,7 @@ int64_new(lua_State *L) {
|
|||||||
if (base < 2) {
|
if (base < 2) {
|
||||||
luaL_error(L, "base must be >= 2");
|
luaL_error(L, "base must be >= 2");
|
||||||
}
|
}
|
||||||
const char * str = lua_tostring(L, 1);
|
const char * str = luaL_checkstring(L, 1);
|
||||||
n = strtoll(str, NULL, base);
|
n = strtoll(str, NULL, base);
|
||||||
_pushint64(L,n);
|
_pushint64(L,n);
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -128,7 +128,12 @@ function skynet.ret(...)
|
|||||||
coroutine.yield("RETURN", ...)
|
coroutine.yield("RETURN", ...)
|
||||||
end
|
end
|
||||||
|
|
||||||
local function default_dispatch(f)
|
local function default_dispatch(f, unknown)
|
||||||
|
unknown = unknown or function (session, msg, sz)
|
||||||
|
local self = skynet.self()
|
||||||
|
print(self, session,msg,sz)
|
||||||
|
error(string.format("%s Unknown session %d", self, session))
|
||||||
|
end
|
||||||
return function(session, address , msg, sz)
|
return function(session, address , msg, sz)
|
||||||
if session == nil then
|
if session == nil then
|
||||||
return
|
return
|
||||||
@@ -141,19 +146,22 @@ local function default_dispatch(f)
|
|||||||
suspend(co, coroutine.resume(co, msg, sz, session, address))
|
suspend(co, coroutine.resume(co, msg, sz, session, address))
|
||||||
else
|
else
|
||||||
local co = session_id_coroutine[session]
|
local co = session_id_coroutine[session]
|
||||||
assert(co, session)
|
if co == nil then
|
||||||
session_id_coroutine[session] = nil
|
unknown(session,msg,sz)
|
||||||
suspend(co, coroutine.resume(co, msg, sz))
|
else
|
||||||
|
session_id_coroutine[session] = nil
|
||||||
|
suspend(co, coroutine.resume(co, msg, sz))
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function skynet.dispatch(f)
|
function skynet.dispatch(f,unknown)
|
||||||
c.callback(default_dispatch(f))
|
c.callback(default_dispatch(f,unknown))
|
||||||
end
|
end
|
||||||
|
|
||||||
function skynet.filter(filter, f)
|
function skynet.filter(filter, f, unknown)
|
||||||
local func = default_dispatch(f)
|
local func = default_dispatch(f, unknown)
|
||||||
c.callback(function (...)
|
c.callback(function (...)
|
||||||
func(filter(...))
|
func(filter(...))
|
||||||
end)
|
end)
|
||||||
@@ -170,4 +178,10 @@ function skynet.start(f)
|
|||||||
session_id_coroutine[tonumber(session)] = co
|
session_id_coroutine[tonumber(session)] = co
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function skynet.newservice(name, ...)
|
||||||
|
local args = { "snlua" , name , ... }
|
||||||
|
local handle = skynet.call(".launcher", table.concat(args," "))
|
||||||
|
return handle
|
||||||
|
end
|
||||||
|
|
||||||
return skynet
|
return skynet
|
||||||
|
|||||||
Reference in New Issue
Block a user