From 6c9ad16077521fd814e2c2a1c82afe9e3207e61c Mon Sep 17 00:00:00 2001 From: Cloud Wu Date: Wed, 29 Oct 2014 16:51:39 +0800 Subject: [PATCH] bugfix: socket open address, and httpd bodylimit --- examples/simpleweb.lua | 1 + lualib-src/lua-netpack.c | 8 ++++---- lualib/http/httpd.lua | 2 +- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/examples/simpleweb.lua b/examples/simpleweb.lua index 234c2d08f..5d38dfb1b 100644 --- a/examples/simpleweb.lua +++ b/examples/simpleweb.lua @@ -66,6 +66,7 @@ skynet.start(function() end local balance = 1 local id = socket.listen("0.0.0.0", 8001) + skynet.error("Listen web port 8001") socket.start(id , function(id, addr) skynet.error(string.format("%s connected, pass it to agent :%08x", addr, agent[balance])) skynet.send(agent[balance], "lua", id) diff --git a/lualib-src/lua-netpack.c b/lualib-src/lua-netpack.c index 1e2ad6328..e424f90cf 100644 --- a/lualib-src/lua-netpack.c +++ b/lualib-src/lua-netpack.c @@ -317,9 +317,9 @@ filter_data(lua_State *L, int fd, uint8_t * buffer, int size) { } static void -pushstring(lua_State *L, const char * msg) { +pushstring(lua_State *L, const char * msg, int size) { if (msg) { - lua_pushstring(L, msg); + lua_pushlstring(L, msg, size); } else { lua_pushliteral(L, ""); } @@ -365,12 +365,12 @@ lfilter(lua_State *L) { lua_pushvalue(L, lua_upvalueindex(TYPE_OPEN)); // ignore listen id (message->id); lua_pushinteger(L, message->ud); - pushstring(L, buffer); + pushstring(L, buffer, size); return 4; case SKYNET_SOCKET_TYPE_ERROR: lua_pushvalue(L, lua_upvalueindex(TYPE_ERROR)); lua_pushinteger(L, message->id); - pushstring(L, buffer); + pushstring(L, buffer, size); return 4; default: // never get here diff --git a/lualib/http/httpd.lua b/lualib/http/httpd.lua index 944c95840..66431894a 100644 --- a/lualib/http/httpd.lua +++ b/lualib/http/httpd.lua @@ -83,7 +83,7 @@ local function readall(readbytes, bodylimit) else -- identity mode if length then - if length > bodylimit then + if bodylimit and length > bodylimit then return 413 end if #body >= length then