From 6c1fa3a184fbfbfc837ea479d277a71480f1fc42 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20P=C3=A9gouri=C3=A9-Gonnard?= Date: Wed, 1 Oct 2014 16:58:16 +0200 Subject: [PATCH] Fix misplaced initialisation of timeout --- include/polarssl/ssl.h | 2 ++ library/ssl_tls.c | 7 +++---- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/include/polarssl/ssl.h b/include/polarssl/ssl.h index f3f357522..9a34449f6 100644 --- a/include/polarssl/ssl.h +++ b/include/polarssl/ssl.h @@ -255,6 +255,8 @@ * * The SENDING state is merged in PREPARING for initial sends, * but is distinct for resends. + * + * Note: initial state is wrong for server, but is not used anyway. */ #define SSL_RETRANS_PREPARING 0 #define SSL_RETRANS_SENDING 1 diff --git a/library/ssl_tls.c b/library/ssl_tls.c index 34ef165c9..6c0f3ea29 100644 --- a/library/ssl_tls.c +++ b/library/ssl_tls.c @@ -2307,9 +2307,8 @@ void ssl_recv_flight_completed( ssl_context *ssl ) /* The next incoming flight will start with this msg_seq */ ssl->handshake->in_flight_start_seq = ssl->handshake->in_msg_seq; - /* Cancel timer and reset timeout value */ + /* Cancel timer */ ssl_set_timer( ssl, 0 ); - ssl_reset_retransmit_timeout( ssl ); if( ssl->in_msgtype == SSL_MSG_HANDSHAKE && ssl->in_msg[0] == SSL_HS_FINISHED ) @@ -2325,6 +2324,7 @@ void ssl_recv_flight_completed( ssl_context *ssl ) */ void ssl_send_flight_completed( ssl_context *ssl ) { + ssl_reset_retransmit_timeout( ssl ); ssl_set_timer( ssl, ssl->handshake->retransmit_timeout ); if( ssl->in_msgtype == SSL_MSG_HANDSHAKE && @@ -4535,8 +4535,7 @@ static int ssl_handshake_init( ssl_context *ssl ) #if defined(POLARSSL_SSL_PROTO_DTLS) ssl->handshake->alt_transform_out = ssl->transform_out; - ssl->handshake->retransmit_timeout = ssl->hs_timeout_min; - + // TODO: not the right place, we may not know endpoint yet if( ssl->endpoint == SSL_IS_CLIENT ) ssl->handshake->retransmit_state = SSL_RETRANS_PREPARING; else