mirror of
https://github.com/cloudwu/skynet.git
synced 2026-07-22 02:53:09 +00:00
Merge remote-tracking branch 'upstream/master'
This commit is contained in:
@@ -200,18 +200,19 @@ void luaV_finishset (lua_State *L, const TValue *t, TValue *key,
|
||||
for (loop = 0; loop < MAXTAGLOOP; loop++) {
|
||||
const TValue *tm;
|
||||
if (oldval != NULL) {
|
||||
lua_assert(ttistable(t) && ttisnil(oldval));
|
||||
Table *h = hvalue(t);
|
||||
lua_assert(ttisnil(oldval));
|
||||
/* must check the metamethod */
|
||||
if ((tm = fasttm(L, hvalue(t)->metatable, TM_NEWINDEX)) == NULL &&
|
||||
if ((tm = fasttm(L, h->metatable, TM_NEWINDEX)) == NULL &&
|
||||
/* no metamethod; is there a previous entry in the table? */
|
||||
(oldval != luaO_nilobject ||
|
||||
/* no previous entry; must create one. (The next test is
|
||||
always true; we only need the assignment.) */
|
||||
(oldval = luaH_newkey(L, hvalue(t), key), 1))) {
|
||||
(oldval = luaH_newkey(L, h, key), 1))) {
|
||||
/* no metamethod and (now) there is an entry with given key */
|
||||
setobj2t(L, cast(TValue *, oldval), val);
|
||||
invalidateTMcache(hvalue(t));
|
||||
luaC_barrierback(L, hvalue(t), val);
|
||||
invalidateTMcache(h);
|
||||
luaC_barrierback(L, h, val);
|
||||
return;
|
||||
}
|
||||
/* else will try the metamethod */
|
||||
|
||||
@@ -197,6 +197,7 @@ function host:dispatch(...)
|
||||
local bin = core.unpack(...)
|
||||
header_tmp.type = nil
|
||||
header_tmp.session = nil
|
||||
header_tmp.ud = nil
|
||||
local header, size = core.decode(self.__package, bin, header_tmp)
|
||||
local content = bin:sub(size + 1)
|
||||
if header.type then
|
||||
@@ -207,9 +208,9 @@ function host:dispatch(...)
|
||||
result = core.decode(proto.request, content)
|
||||
end
|
||||
if header_tmp.session then
|
||||
return "REQUEST", proto.name, result, gen_response(self, proto.response, header_tmp.session)
|
||||
return "REQUEST", proto.name, result, gen_response(self, proto.response, header_tmp.session), header.ud
|
||||
else
|
||||
return "REQUEST", proto.name, result
|
||||
return "REQUEST", proto.name, result, nil, header.ud
|
||||
end
|
||||
else
|
||||
-- response
|
||||
@@ -217,19 +218,20 @@ function host:dispatch(...)
|
||||
local response = assert(self.__session[session], "Unknown session")
|
||||
self.__session[session] = nil
|
||||
if response == true then
|
||||
return "RESPONSE", session
|
||||
return "RESPONSE", session, nil, header.ud
|
||||
else
|
||||
local result = core.decode(response, content)
|
||||
return "RESPONSE", session, result
|
||||
return "RESPONSE", session, result, header.ud
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function host:attach(sp)
|
||||
return function(name, args, session)
|
||||
return function(name, args, session, ud)
|
||||
local proto = queryproto(sp, name)
|
||||
header_tmp.type = proto.tag
|
||||
header_tmp.session = session
|
||||
header_tmp.ud = ud
|
||||
local header = core.encode(self.__package, header_tmp)
|
||||
|
||||
if session then
|
||||
|
||||
@@ -84,7 +84,7 @@ skynet_mq_create(uint32_t handle) {
|
||||
SPIN_INIT(q)
|
||||
// When the queue is create (always between service create and service init) ,
|
||||
// set in_global flag to avoid push it to global queue .
|
||||
// If the service init success, skynet_context_new will call skynet_mq_force_push to push it to global queue.
|
||||
// If the service init success, skynet_context_new will call skynet_mq_push to push it to global queue.
|
||||
q->in_global = MQ_IN_GLOBAL;
|
||||
q->release = 0;
|
||||
q->overload = 0;
|
||||
|
||||
@@ -16,7 +16,7 @@ struct socket_server;
|
||||
struct socket_message {
|
||||
int id;
|
||||
uintptr_t opaque;
|
||||
int ud; // for accept, ud is listen id ; for data, ud is size of data
|
||||
int ud; // for accept, ud is new connection id ; for data, ud is size of data
|
||||
char * data;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user