ESP8266 Developer Zone The Official ESP8266 Forum 2015-07-09T19:58:16+08:00 https://bbs.espressif.com:443/feed.php?f=7&t=704 2015-07-09T19:58:16+08:00 2015-07-09T19:58:16+08:00 https://bbs.espressif.com:443/viewtopic.php?t=704&p=2601#p2601 <![CDATA[Re: SSL crash]]>
The problem is a bit different.
You have a client and a server, T is time T+X relative time.

Client: Server:
T+0
user_tcp_recv_cb(...)
{
does os post task
}

T+1: closes the connection
T+2:
app receives disconnected callback and frees the connection.

T+3:
Now the SDK runs the posted task from the tcp_recv_cb
and tries to disconnect the connection again. -> BOOM



I've got it working but i'm not sure it is not 'just working'.

Thanks one more time!

Statistics: Posted by zaxl — Thu Jul 09, 2015 7:58 pm


]]>
2015-07-09T15:44:11+08:00 2015-07-09T15:44:11+08:00 https://bbs.espressif.com:443/viewtopic.php?t=704&p=2596#p2596 <![CDATA[Re: SSL crash]]>
Please refer to SSL demo here http://bbs.espressif.com/viewtopic.php?f=21&t=389

Add code below to disconnect

Code:

os_event_t *testQueue;
#define TEST_QUEUE_LEN 4

void test_task(os_event_t *e){
    os_printf("test_task !!! \r\n");
    espconn_secure_disconnect(&user_tcp_conn);
}

LOCAL void ICACHE_FLASH_ATTR
user_tcp_recv_cb(void *arg, char *pusrdata, unsigned short length)
{
   //received some data from tcp connection
   
    os_printf("tcp recv !!! %s \r\n", pusrdata);
   
   testQueue = (os_event_t*) os_malloc(sizeof(os_event_t) * TEST_QUEUE_LEN);
   system_os_task(test_task, 0, testQueue, TEST_QUEUE_LEN);
   system_os_post(0, 0, 0);

}


More details about "system_os_task" and "system_os_post" please refer to documentation "2C-ESP8266__SDK__Programming Guide"

Thanks for your interest in Espressif Systems and ESP8266 !

Statistics: Posted by ESP_Faye — Thu Jul 09, 2015 3:44 pm


]]>
2015-07-08T15:00:46+08:00 2015-07-08T15:00:46+08:00 https://bbs.espressif.com:443/viewtopic.php?t=704&p=2570#p2570 <![CDATA[Re: SSL crash]]>
thanks for the fast replay!

But if i use an os task to close the connection there is a race condition:

recv callback:
system_os_post (..., close_connection, conn)
disconnected cb:
free connection

close_connection_os_task:
conn -> now points to a freed memory crash again



Is there a warranty that the os task will run before any other callbacks? Same goes for the case when using some context structure instead of directly using espconn.

Statistics: Posted by zaxl — Wed Jul 08, 2015 3:00 pm


]]>
2015-07-08T11:23:22+08:00 2015-07-08T11:23:22+08:00 https://bbs.espressif.com:443/viewtopic.php?t=704&p=2566#p2566 <![CDATA[Re: SSL crash]]>
Sorry for the inconvenience.

Please don’t call espconn_disconnect (or espconn_secure_disconnect) to break the TCP connection in any espconn callback.
If it is needed, please use system_os_task and system_os_post to trigger the disconnection ( espconn_disconnect or espconn_secure_disconnect).

Statistics: Posted by ESP_Faye — Wed Jul 08, 2015 11:23 am


]]>
2015-07-07T23:16:28+08:00 2015-07-07T23:16:28+08:00 https://bbs.espressif.com:443/viewtopic.php?t=704&p=2554#p2554 <![CDATA[SSL crash]]>
If i call espconn_secure_disconnect() from receive_callback() the SDK randomly crashes crashes - tried with both 1.1.2 and 1.2 .

I'm using - https://github.com/zazolabs/esphttpclient.git

Statistics: Posted by zaxl — Tue Jul 07, 2015 11:16 pm


]]>