diff options
author | Nikos Mavrogiannopoulos <nmav@gnutls.org> | 2019-02-23 21:02:56 +0100 |
---|---|---|
committer | Nikos Mavrogiannopoulos <nmav@redhat.com> | 2019-03-19 17:04:07 +0100 |
commit | 755196a8c14e435816b633a62158b4868f784338 (patch) | |
tree | b1582dd9171a0dcafa394bbef0863a485c44e92d /lib/session.c | |
parent | b6c6e148b542a3ac3b0c407708fbc86e884d4f82 (diff) | |
download | gnutls-755196a8c14e435816b633a62158b4868f784338.tar.gz |
Improved estimation of wait in gnutls_session_get_data2tmp-improve-session-resumption
Previously we would wait an arbitrary value of 50ms for the
server to send session tickets. This change makes the client
wait for the estimated single trip time + 60 ms for the server
to calculate the session tickets. This improves the chance
to obtain tickets from internet servers during the call of
gnutls_session_get_data2().
Resolves: #706
Signed-off-by: Nikos Mavrogiannopoulos <nmav@gnutls.org>
Diffstat (limited to 'lib/session.c')
-rw-r--r-- | lib/session.c | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/lib/session.c b/lib/session.c index 12f41797ec..10b19abb4e 100644 --- a/lib/session.c +++ b/lib/session.c @@ -28,6 +28,7 @@ #include "buffers.h" #include "state.h" #include "ext/cert_types.h" +#include <minmax.h> /** * gnutls_session_get_data: @@ -99,8 +100,10 @@ gnutls_session_get_data(gnutls_session_t session, * is received by the client. To ensure that such a ticket has been received use * gnutls_session_get_flags() and check for flag %GNUTLS_SFLAGS_SESSION_TICKET; * if this flag is not set, this function will wait for a new ticket within - * 50ms, and if not received will return dummy data which cannot lead to - * resumption. To get notified when new tickets are received by the server + * an estimated rountrip, and if not received will return dummy data which + * cannot lead to resumption. + * + * To get notified when new tickets are received by the server * use gnutls_handshake_set_hook_function() to wait for %GNUTLS_HANDSHAKE_NEW_SESSION_TICKET * messages. Each call of gnutls_session_get_data2() after a ticket is * received, will return session resumption data corresponding to the last @@ -120,8 +123,13 @@ gnutls_session_get_data2(gnutls_session_t session, gnutls_datum_t *data) } if (vers->tls13_sem && !(session->internals.hsk_flags & HSK_TICKET_RECEIVED)) { - /* wait for a message with timeout of 1ms */ - ret = _gnutls_recv_in_buffers(session, GNUTLS_APPLICATION_DATA, -1, 50); + unsigned ertt = session->internals.ertt; + /* use our estimation of round-trip + some time for the server to calculate + * the value(s). */ + ertt += 60; + + /* wait for a message with timeout */ + ret = _gnutls_recv_in_buffers(session, GNUTLS_APPLICATION_DATA, -1, ertt); if (ret < 0 && (gnutls_error_is_fatal(ret) && ret != GNUTLS_E_TIMEDOUT)) { return gnutls_assert_val(ret); } |