mirror of https://github.com/ARMmbed/mbed-os.git
Merge pull request #15111 from world-direct/feature/dtlserror
DTLSSocket - destruction while handshaking lead to errorpull/15169/head
commit
0db0445a97
|
@ -40,6 +40,14 @@ public:
|
||||||
* @param control Transport control mode. See @ref control_transport.
|
* @param control Transport control mode. See @ref control_transport.
|
||||||
*/
|
*/
|
||||||
DTLSSocketWrapper(Socket *transport, const char *hostname = NULL, control_transport control = TRANSPORT_CONNECT_AND_CLOSE);
|
DTLSSocketWrapper(Socket *transport, const char *hostname = NULL, control_transport control = TRANSPORT_CONNECT_AND_CLOSE);
|
||||||
|
|
||||||
|
/** Destroy a socket wrapper.
|
||||||
|
*
|
||||||
|
* Closes socket wrapper if the socket wrapper is still opened.
|
||||||
|
*/
|
||||||
|
~DTLSSocketWrapper();
|
||||||
|
|
||||||
|
nsapi_error_t close() override;
|
||||||
private:
|
private:
|
||||||
static void timing_set_delay(void *ctx, uint32_t int_ms, uint32_t fin_ms);
|
static void timing_set_delay(void *ctx, uint32_t int_ms, uint32_t fin_ms);
|
||||||
static int timing_get_delay(void *ctx);
|
static int timing_get_delay(void *ctx);
|
||||||
|
|
|
@ -36,6 +36,11 @@ DTLSSocketWrapper::DTLSSocketWrapper(Socket *transport, const char *hostname, co
|
||||||
#endif /* !defined(MBEDTLS_SSL_CONF_SET_TIMER) && !defined(MBEDTLS_SSL_CONF_GET_TIMER) */
|
#endif /* !defined(MBEDTLS_SSL_CONF_SET_TIMER) && !defined(MBEDTLS_SSL_CONF_GET_TIMER) */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DTLSSocketWrapper::~DTLSSocketWrapper()
|
||||||
|
{
|
||||||
|
close();
|
||||||
|
}
|
||||||
|
|
||||||
void DTLSSocketWrapper::timing_set_delay(void *ctx, uint32_t int_ms, uint32_t fin_ms)
|
void DTLSSocketWrapper::timing_set_delay(void *ctx, uint32_t int_ms, uint32_t fin_ms)
|
||||||
{
|
{
|
||||||
DTLSSocketWrapper *context = static_cast<DTLSSocketWrapper *>(ctx);
|
DTLSSocketWrapper *context = static_cast<DTLSSocketWrapper *>(ctx);
|
||||||
|
@ -74,6 +79,16 @@ int DTLSSocketWrapper::timing_get_delay(void *ctx)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
nsapi_error_t DTLSSocketWrapper::close()
|
||||||
|
{
|
||||||
|
if (_timer_event_id != 0) {
|
||||||
|
mbed::mbed_event_queue()->cancel(_timer_event_id);
|
||||||
|
_timer_event_id = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return TLSSocketWrapper::close();
|
||||||
|
}
|
||||||
|
|
||||||
void DTLSSocketWrapper::timer_event(void)
|
void DTLSSocketWrapper::timer_event(void)
|
||||||
{
|
{
|
||||||
_timer_expired = true;
|
_timer_expired = true;
|
||||||
|
|
Loading…
Reference in New Issue