mirror of
https://github.com/cloudwu/skynet.git
synced 2026-07-22 02:53:09 +00:00
remove unused netpack c api
This commit is contained in:
@@ -448,57 +448,6 @@ lpack(lua_State *L) {
|
||||
return 2;
|
||||
}
|
||||
|
||||
static int
|
||||
lpack_string(lua_State *L) {
|
||||
uint8_t tmp[SMALLSTRING+2];
|
||||
size_t len;
|
||||
uint8_t *buffer;
|
||||
const char * ptr = tolstring(L, &len, 1);
|
||||
if (len > 0x10000) {
|
||||
return luaL_error(L, "Invalid size (too long) of data : %d", (int)len);
|
||||
}
|
||||
|
||||
if (len <= SMALLSTRING) {
|
||||
buffer = tmp;
|
||||
} else {
|
||||
buffer = lua_newuserdata(L, len + 2);
|
||||
}
|
||||
|
||||
write_size(buffer, len);
|
||||
memcpy(buffer+2, ptr, len);
|
||||
lua_pushlstring(L, (const char *)buffer, len+2);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int
|
||||
lpack_padding(lua_State *L) {
|
||||
uint8_t tmp[SMALLSTRING+2];
|
||||
size_t content_sz;
|
||||
uint8_t *buffer;
|
||||
const char * ptr = tolstring(L, &content_sz, 2);
|
||||
size_t cookie_sz = 0;
|
||||
const char * cookie = luaL_checklstring(L,1,&cookie_sz);
|
||||
size_t len = cookie_sz + content_sz;
|
||||
|
||||
if (len > 0x10000) {
|
||||
return luaL_error(L, "Invalid size (too long) of data : %d", (int)len);
|
||||
}
|
||||
|
||||
if (len <= SMALLSTRING) {
|
||||
buffer = tmp;
|
||||
} else {
|
||||
buffer = lua_newuserdata(L, len + 2);
|
||||
}
|
||||
|
||||
write_size(buffer, len);
|
||||
memcpy(buffer+2, ptr, content_sz);
|
||||
memcpy(buffer+2+content_sz, cookie, cookie_sz);
|
||||
lua_pushlstring(L, (const char *)buffer, len+2);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int
|
||||
ltostring(lua_State *L) {
|
||||
void * ptr = lua_touserdata(L, 1);
|
||||
@@ -518,8 +467,6 @@ luaopen_netpack(lua_State *L) {
|
||||
luaL_Reg l[] = {
|
||||
{ "pop", lpop },
|
||||
{ "pack", lpack },
|
||||
{ "pack_string", lpack_string },
|
||||
{ "pack_padding", lpack_padding },
|
||||
{ "clear", lclear },
|
||||
{ "tostring", ltostring },
|
||||
{ NULL, NULL },
|
||||
|
||||
@@ -236,7 +236,7 @@ function server.start(conf)
|
||||
|
||||
local function do_request(fd, message)
|
||||
local u = assert(connection[fd], "invalid fd")
|
||||
local session = string.unpack("I4", message, -4)
|
||||
local session = string.unpack(">I4", message, -4)
|
||||
message = message:sub(1,-5)
|
||||
local p = u.response[session]
|
||||
if p then
|
||||
@@ -257,16 +257,16 @@ function server.start(conf)
|
||||
p = { fd }
|
||||
u.response[session] = p
|
||||
local ok, result = pcall(conf.request_handler, u.username, message)
|
||||
result = result or ""
|
||||
-- NOTICE: YIELD here, socket may close.
|
||||
result = result or ""
|
||||
if not ok then
|
||||
skynet.error(result)
|
||||
result = "\0" .. session
|
||||
result = string.pack(">BI4", 0, session)
|
||||
else
|
||||
result = result .. '\1' .. session
|
||||
result = result .. string.pack(">BI4", 1, session)
|
||||
end
|
||||
|
||||
p[2] = netpack.pack_string(result)
|
||||
p[2] = string.pack(">s2",result)
|
||||
p[3] = u.version
|
||||
p[4] = u.index
|
||||
else
|
||||
|
||||
Reference in New Issue
Block a user