sandbox / mbed-client-mbedtls

Fork of mbed-client-mbedtls by Christopher Haster

Files at this revision

API Documentation at this revision

Comitter:
yogpan01
Date:
Thu Apr 07 11:05:45 2016 +0000
Parent:
5:840aa460b437
Commit message:
Merge fixes from github master

Changed in this revision

source/m2mconnectionsecuritypimpl.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/source/m2mconnectionsecuritypimpl.cpp	Thu Apr 07 02:01:28 2016 +0300
+++ b/source/m2mconnectionsecuritypimpl.cpp	Thu Apr 07 11:05:45 2016 +0000
@@ -21,7 +21,7 @@
 #include "mbed-trace/mbed_trace.h"
 #include <string.h>
 
-#define TRACEW_GROUP "mClt"
+#define TRACE_GROUP "mClt"
 
 void mbedtls_timing_set_delay( void *data, uint32_t int_ms, uint32_t fin_ms );
 int mbedtls_timing_get_delay( void *data );
@@ -237,11 +237,19 @@
     mbedtls_ssl_set_timer_cb( &_ssl, _timer, mbedtls_timing_set_delay,
                                             mbedtls_timing_get_delay );
 
-    do ret = mbedtls_ssl_handshake( &_ssl );
+    int retry_count = 0;
+    do
+    {
+       ret = mbedtls_ssl_handshake( &_ssl );
+       if (ret == -1) {
+           mbedtls_ssl_session_reset( &_ssl );
+           retry_count++;
+           tr_error("M2MConnectionSecurityPimpl::connect - start handshake again");
+       }
+    }
     while( ret == MBEDTLS_ERR_SSL_WANT_READ ||
-           ret == MBEDTLS_ERR_SSL_WANT_WRITE );
-
-    tr_debug("M2MConnectionSecurityPimpl::connect - handshake, ret: %d", ret);
+           ret == MBEDTLS_ERR_SSL_WANT_WRITE ||
+           (ret == -1 && retry_count <= RETRY_COUNT));
 
     if( ret != 0 ) {
         tr_error("M2MConnectionSecurityPimpl::connect - handshake failed");