Commit dec47d53 authored by funshine's avatar funshine
Browse files

fix #185

parent 7f970df7
......@@ -725,8 +725,15 @@ static int mqtt_socket_connect( lua_State* L )
if(mud == NULL)
return 0;
if(mud->pesp_conn)
c_free(mud->pesp_conn);
if(mud->pesp_conn){ //TODO: should I free tcp struct directly or ask user to call close()???
mud->pesp_conn->reverse = NULL;
if(mud->pesp_conn->proto.tcp)
c_free(mud->pesp_conn->proto.tcp);
mud->pesp_conn->proto.tcp = NULL;
c_free(mud->pesp_conn);
mud->pesp_conn = NULL;
}
struct espconn *pesp_conn = NULL;
pesp_conn = mud->pesp_conn = (struct espconn *)c_zalloc(sizeof(struct espconn));
if(!pesp_conn)
......
......@@ -665,6 +665,10 @@ static int net_start( lua_State* L, const char* mt )
return 0;
}
if(nud->pesp_conn == NULL){
NODE_DBG("nud->pesp_conn is NULL.\n");
return 0;
}
pesp_conn = nud->pesp_conn;
port = luaL_checkinteger( L, stack );
stack++;
......@@ -1074,6 +1078,10 @@ static int net_dns( lua_State* L, const char* mt )
return 0;
}
if(nud->pesp_conn == NULL){
NODE_DBG("nud->pesp_conn is NULL.\n");
return 0;
}
pesp_conn = nud->pesp_conn;
if(!isserver || pesp_conn->type == ESPCONN_UDP){ // self_ref is only needed by socket userdata, or udp server
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment