mirror of
https://github.com/cloudwu/skynet.git
synced 2026-07-24 12:20:41 +00:00
add skynet.context_ptr() & noneblocking socket.close
This commit is contained in:
@@ -385,6 +385,14 @@ _harbor(lua_State *L) {
|
|||||||
return 2;
|
return 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
_context(lua_State *L) {
|
||||||
|
struct skynet_context * context = lua_touserdata(L, lua_upvalueindex(1));
|
||||||
|
lua_pushlightuserdata(L, context);
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
// trace api
|
// trace api
|
||||||
static int
|
static int
|
||||||
_trace_new(lua_State *L) {
|
_trace_new(lua_State *L) {
|
||||||
@@ -465,6 +473,7 @@ luaopen_skynet_c(lua_State *L) {
|
|||||||
{ "error", _error },
|
{ "error", _error },
|
||||||
{ "tostring", _tostring },
|
{ "tostring", _tostring },
|
||||||
{ "harbor", _harbor },
|
{ "harbor", _harbor },
|
||||||
|
{ "context", _context },
|
||||||
{ NULL, NULL },
|
{ NULL, NULL },
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -615,4 +615,8 @@ function skynet.abort()
|
|||||||
c.command("ABORT")
|
c.command("ABORT")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function skynet.context_ptr()
|
||||||
|
return c.context()
|
||||||
|
end
|
||||||
|
|
||||||
return skynet
|
return skynet
|
||||||
|
|||||||
@@ -49,6 +49,10 @@ struct socket_pool {
|
|||||||
|
|
||||||
static void
|
static void
|
||||||
reply(struct skynet_context * ctx, uint32_t source, int session, char * cmd, int sz) {
|
reply(struct skynet_context * ctx, uint32_t source, int session, char * cmd, int sz) {
|
||||||
|
if (session == 0) {
|
||||||
|
// don't reply when session == 0
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (sz < 0) {
|
if (sz < 0) {
|
||||||
sz = strlen(cmd);
|
sz = strlen(cmd);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user