Skip to content

Commit

Permalink
throw error when skynet.exit
Browse files Browse the repository at this point in the history
  • Loading branch information
cloudwu committed Jul 3, 2014
1 parent 711c04e commit f874fdc
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 3 deletions.
5 changes: 5 additions & 0 deletions HISTORY.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
Dev version
-----------
* add SERVICE_NAME in loader
* throw error back when skynet.error

v0.4.0 (2014-6-30)
-----------
* Optimize redis driver `compose_message`.
Expand Down
4 changes: 3 additions & 1 deletion lualib/loader.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@ for word in string.gmatch(..., "%S+") do
table.insert(args, word)
end

SERVICE_NAME = args[1]

local main, pattern

local err = {}
for pat in string.gmatch(LUA_SERVICE, "([^;]+);*") do
local filename = string.gsub(pat, "?", args[1])
local filename = string.gsub(pat, "?", SERVICE_NAME)
local f, msg = loadfile(filename)
if not f then
table.insert(err, msg)
Expand Down
7 changes: 7 additions & 0 deletions lualib/skynet.lua
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,13 @@ end

function skynet.exit()
skynet.send(".launcher","lua","REMOVE",skynet.self())
for co, session in pairs(session_coroutine_id) do
local address = session_coroutine_address[co]
local self = skynet.self()
if session~=0 and address then
skynet.redirect(self, address, "error", session, "")
end
end
c.command("EXIT")
end

Expand Down
2 changes: 1 addition & 1 deletion test/testdeadcall.lua
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ end)
else

skynet.start(function()
local test = skynet.newservice("testdeadcall", "test") -- launch self in test mode
local test = skynet.newservice(SERVICE_NAME, "test") -- launch self in test mode

print(pcall(function()
skynet.send(test,"lua", "hello world")
Expand Down
2 changes: 1 addition & 1 deletion test/testmulticast.lua
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ skynet.start(function()
local channel = mc.new()
print("New channel", channel)
for i=1,10 do
local sub = skynet.newservice("testmulticast", "sub")
local sub = skynet.newservice(SERVICE_NAME, "sub")
skynet.call(sub, "lua", "init", channel.channel)
end

Expand Down

0 comments on commit f874fdc

Please sign in to comment.