SSL crash
Re: SSL crash
Postby ESP_Faye » Wed Jul 08, 2015 11:23 am
Hi,
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).
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).
Re: SSL crash
Postby zaxl » Wed Jul 08, 2015 3:00 pm
Hi,
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.
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.
Regards,
zaxl
zaxl
Re: SSL crash
Postby ESP_Faye » Thu Jul 09, 2015 3:44 pm
Hi,
Please refer to SSL demo here http://bbs.espressif.com/viewtopic.php?f=21&t=389
Add code below to disconnect
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 !
Please refer to SSL demo here http://bbs.espressif.com/viewtopic.php?f=21&t=389
Add code below to disconnect
Code: Select all
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 !
Re: SSL crash
Postby zaxl » Thu Jul 09, 2015 7:58 pm
Hi,
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!
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!
Regards,
zaxl
zaxl
Who is online
Users browsing this forum: No registered users and 30 guests
Login
Newbies Start Here
Are you new to ESP8266?
Unsure what to do?
Dunno where to start?
Start right here!
Latest SDK
Documentation
Complete listing of the official ESP8266 related documentation release by ESPRESSIF!
Must read here!
- All times are UTC+08:00
- Top
- Delete all board cookies
About Us
Espressif Systems is a fabless semiconductor company providing cutting-edge low power WiFi SoCs and wireless solutions for wireless communications and Internet of Things applications. We are the manufacturer of ESP8266EX.