From d28a2c9edaf66a04caacf50a857e5e532923648a Mon Sep 17 00:00:00 2001 From: funshine Date: Wed, 11 Mar 2015 13:21:19 +0800 Subject: [PATCH] add interger version release, fix #234, #252, #246 --- .travis.yml | 1 - README.md | 6 ++++++ app/include/user_version.h | 2 +- app/modules/net.c | 25 ++++++++++++++++++------- examples/fragment.lua | 8 ++++++++ 5 files changed, 33 insertions(+), 9 deletions(-) diff --git a/.travis.yml b/.travis.yml index 1f3d0e43..894f2fd0 100644 --- a/.travis.yml +++ b/.travis.yml @@ -16,7 +16,6 @@ script: - cd bin/ - file_name_integer="nodemcu_integer_${TRAVIS_TAG}.bin" - srec_cat -output ${file_name_integer} -binary 0x00000.bin -binary -fill 0xff 0x00000 0x10000 0x10000.bin -binary -offset 0x10000 -- ls deploy: provider: releases api_key: diff --git a/README.md b/README.md index 918fe021..d388b0a8 100644 --- a/README.md +++ b/README.md @@ -33,6 +33,12 @@ Tencent QQ group: 309957875
- cross compiler (done) # Change log +2015-03-11
+fix bugs of spiffs.
+build both float and integer version [latest releases](https://github.com/nodemcu/nodemcu-firmware/releases/latest).
+fix tmr.time().
+fix memory leak when DNS fail. + 2015-03-10
update to the recent spiffs.
add file.fsinfo() api, usage: remain, used, total = file.fsinfo().
diff --git a/app/include/user_version.h b/app/include/user_version.h index 4a7f5f6d..ed2b0d6d 100644 --- a/app/include/user_version.h +++ b/app/include/user_version.h @@ -7,6 +7,6 @@ #define NODE_VERSION_INTERNAL 0U #define NODE_VERSION "NodeMCU 0.9.5" -#define BUILD_DATE "build 20150310" +#define BUILD_DATE "build 20150311" #endif /* __USER_VERSION_H__ */ diff --git a/app/modules/net.c b/app/modules/net.c index 5b9dba9d..7fd785ab 100644 --- a/app/modules/net.c +++ b/app/modules/net.c @@ -200,10 +200,15 @@ static void net_dns_found(const char *name, ip_addr_t *ipaddr, void *arg) return; } + if(nud->self_ref == LUA_NOREF){ + NODE_DBG("self_ref null.\n"); + return; + } + if(ipaddr == NULL) { NODE_ERR( "DNS Fail!\n" ); - return; + goto end; } // ipaddr->addr is a uint32_t ip @@ -214,16 +219,12 @@ static void net_dns_found(const char *name, ip_addr_t *ipaddr, void *arg) c_sprintf(ip_str, IPSTR, IP2STR(&(ipaddr->addr))); } - if(nud->self_ref == LUA_NOREF){ - NODE_DBG("self_ref null.\n"); - return; - } - lua_rawgeti(gL, LUA_REGISTRYINDEX, nud->cb_dns_found_ref); // the callback function lua_rawgeti(gL, LUA_REGISTRYINDEX, nud->self_ref); // pass the userdata(conn) to callback func in lua lua_pushstring(gL, ip_str); // the ip para lua_call(gL, 2, 0); +end: if((pesp_conn->type == ESPCONN_TCP && pesp_conn->proto.tcp->remote_port == 0) || (pesp_conn->type == ESPCONN_UDP && pesp_conn->proto.udp->remote_port == 0) ){ lua_gc(gL, LUA_GCSTOP, 0); @@ -597,12 +598,22 @@ static void socket_dns_found(const char *name, ip_addr_t *ipaddr, void *arg) NODE_DBG("pesp_conn null.\n"); return; } - + lnet_userdata *nud = (lnet_userdata *)pesp_conn->reverse; + if(nud == NULL) + return; + if(gL == NULL) + return; if(ipaddr == NULL) { dns_reconn_count++; if( dns_reconn_count >= 5 ){ NODE_ERR( "DNS Fail!\n" ); + lua_gc(gL, LUA_GCSTOP, 0); + if(nud->self_ref != LUA_NOREF){ + luaL_unref(gL, LUA_REGISTRYINDEX, nud->self_ref); + nud->self_ref = LUA_NOREF; // unref this, and the net.socket userdata will delete it self + } + lua_gc(gL, LUA_GCRESTART, 0); return; } NODE_ERR( "DNS retry %d!\n", dns_reconn_count ); diff --git a/examples/fragment.lua b/examples/fragment.lua index 9c531281..c1cc4fb7 100644 --- a/examples/fragment.lua +++ b/examples/fragment.lua @@ -370,3 +370,11 @@ for n,s in pairs(file.list()) do print(n.." size: "..s) end file.remove("test1.txt") for n,s in pairs(file.list()) do print(n.." size: "..s) end file.open("test2.txt", "a+") for i = 1, 1*1000 do file.write("x") end file.close() print("Done.") + + +function TestDNSLeak() + c=net.createConnection(net.TCP, 0) + c:connect(80, "bad-name.tlddfdf") + tmr.alarm(1, 3000, 0, function() print("hack socket close, MEM: "..node.heap()) c:close() end) -- socket timeout hack + print("MEM: "..node.heap()) +end