Browse Source

add interger version release, fix #234, #252, #246

funshine 9 years ago
parent
commit
d28a2c9eda
5 changed files with 33 additions and 9 deletions
  1. 0 1
      .travis.yml
  2. 6 0
      README.md
  3. 1 1
      app/include/user_version.h
  4. 18 7
      app/modules/net.c
  5. 8 0
      examples/fragment.lua

+ 0 - 1
.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:

+ 6 - 0
README.md

@@ -33,6 +33,12 @@ Tencent QQ group: 309957875<br />
 - cross compiler (done)
 
 # Change log
+2015-03-11<br />
+fix bugs of spiffs.<br />
+build both float and integer version [latest releases](https://github.com/nodemcu/nodemcu-firmware/releases/latest).<br />
+fix tmr.time().<br />
+fix memory leak when DNS fail.
+
 2015-03-10<br />
 update to the recent spiffs.<br />
 add file.fsinfo() api, usage: remain, used, total = file.fsinfo().<br />

+ 1 - 1
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__ */

+ 18 - 7
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 );

+ 8 - 0
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