This commit is contained in:
funshine 2015-02-07 23:45:01 +08:00
parent 7f970df70b
commit dec47d5372
2 changed files with 17 additions and 2 deletions

View File

@ -725,8 +725,15 @@ static int mqtt_socket_connect( lua_State* L )
if(mud == NULL) if(mud == NULL)
return 0; return 0;
if(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); c_free(mud->pesp_conn);
mud->pesp_conn = NULL;
}
struct espconn *pesp_conn = NULL; struct espconn *pesp_conn = NULL;
pesp_conn = mud->pesp_conn = (struct espconn *)c_zalloc(sizeof(struct espconn)); pesp_conn = mud->pesp_conn = (struct espconn *)c_zalloc(sizeof(struct espconn));
if(!pesp_conn) if(!pesp_conn)

View File

@ -665,6 +665,10 @@ static int net_start( lua_State* L, const char* mt )
return 0; return 0;
} }
if(nud->pesp_conn == NULL){
NODE_DBG("nud->pesp_conn is NULL.\n");
return 0;
}
pesp_conn = nud->pesp_conn; pesp_conn = nud->pesp_conn;
port = luaL_checkinteger( L, stack ); port = luaL_checkinteger( L, stack );
stack++; stack++;
@ -1074,6 +1078,10 @@ static int net_dns( lua_State* L, const char* mt )
return 0; return 0;
} }
if(nud->pesp_conn == NULL){
NODE_DBG("nud->pesp_conn is NULL.\n");
return 0;
}
pesp_conn = nud->pesp_conn; pesp_conn = nud->pesp_conn;
if(!isserver || pesp_conn->type == ESPCONN_UDP){ // self_ref is only needed by socket userdata, or udp server if(!isserver || pesp_conn->type == ESPCONN_UDP){ // self_ref is only needed by socket userdata, or udp server