mirror of
https://github.com/cloudwu/skynet.git
synced 2026-07-22 02:53:09 +00:00
clustersender tracetag bug
This commit is contained in:
@@ -1,23 +1,14 @@
|
||||
local skynet = require "skynet"
|
||||
require "skynet.manager"
|
||||
local sc = require "skynet.socketchannel"
|
||||
local socket = require "skynet.socket"
|
||||
local cluster = require "skynet.cluster.core"
|
||||
|
||||
local config_name = skynet.getenv "cluster"
|
||||
local node_address = {}
|
||||
local node_session = {}
|
||||
local node_sender = {}
|
||||
local command = {}
|
||||
local config = {}
|
||||
local nodename = cluster.nodename()
|
||||
|
||||
local function read_response(sock)
|
||||
local sz = socket.header(sock:read(2))
|
||||
local msg = sock:read(sz)
|
||||
return cluster.unpackresponse(msg) -- session, ok, data, padding
|
||||
end
|
||||
|
||||
local connecting = {}
|
||||
|
||||
local function open_channel(t, key)
|
||||
@@ -44,7 +35,7 @@ local function open_channel(t, key)
|
||||
local host, port = string.match(address, "([^:]+):(.*)$")
|
||||
c = node_sender[key]
|
||||
if c == nil then
|
||||
c = skynet.newservice "clustersender"
|
||||
c = skynet.newservice("clustersender", key, nodename)
|
||||
if node_sender[key] then
|
||||
-- double check
|
||||
skynet.kill(c)
|
||||
|
||||
@@ -2,21 +2,21 @@ local skynet = require "skynet"
|
||||
local sc = require "skynet.socketchannel"
|
||||
local socket = require "skynet.socket"
|
||||
local cluster = require "skynet.cluster.core"
|
||||
local ignoreret = skynet.ignoreret
|
||||
|
||||
local channel
|
||||
local session = 1
|
||||
local node, nodename = ...
|
||||
|
||||
local command = {}
|
||||
local waiting = {}
|
||||
|
||||
|
||||
local function send_request(addr, msg, sz)
|
||||
-- msg is a local pointer, cluster.packrequest will free it
|
||||
local current_session = session
|
||||
local request, new_session, padding = cluster.packrequest(addr, session, msg, sz)
|
||||
session = new_session
|
||||
|
||||
-- node_channel[node] may yield or throw error
|
||||
local tracetag = skynet.tracetag()
|
||||
if tracetag then
|
||||
if tracetag:sub(1,1) ~= "(" then
|
||||
@@ -63,7 +63,6 @@ function command.push(addr, msg, sz)
|
||||
session = new_session
|
||||
end
|
||||
|
||||
-- node_channel[node] may yield or throw error
|
||||
channel:request(request, nil, padding)
|
||||
end
|
||||
|
||||
@@ -80,7 +79,7 @@ function command.changenode(host, port)
|
||||
response = read_response,
|
||||
nodelay = true,
|
||||
}
|
||||
succ, err = pcall(c.connect, c, true)
|
||||
local succ, err = pcall(c.connect, c, true)
|
||||
if channel then
|
||||
channel:close()
|
||||
end
|
||||
@@ -103,6 +102,3 @@ skynet.start(function()
|
||||
f(...)
|
||||
end)
|
||||
end)
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user