Fix misplaced initialisation of timeout
diff --git a/include/polarssl/ssl.h b/include/polarssl/ssl.h
index f3f3575..9a34449 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 34ef165..6c0f3ea 100644
--- a/library/ssl_tls.c
+++ b/library/ssl_tls.c
@@ -2307,9 +2307,8 @@
     /* 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_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 @@
 #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