diff options
Diffstat (limited to 'lib/gnutls_handshake.c')
-rw-r--r-- | lib/gnutls_handshake.c | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/lib/gnutls_handshake.c b/lib/gnutls_handshake.c index dc2da48e93..3f30e52d39 100644 --- a/lib/gnutls_handshake.c +++ b/lib/gnutls_handshake.c @@ -2364,9 +2364,31 @@ cleanup: int gnutls_handshake (gnutls_session_t session) { + return gnutls_handshake_timeout( session, 0); +} + +/** + * gnutls_handshake_timeout: + * @session: is a #gnutls_session_t structure. + * @sec: is a timeout value in seconds + * + * This function is identical to the gnutls_handshake() but + * it also ensures that the handshake is completed within + * the provided timeout value. + * + * Returns: %GNUTLS_E_SUCCESS on success, %GNUTLS_E_TIMED_OUT on timeout, otherwise a negative error code. + **/ +int +gnutls_handshake_timeout (gnutls_session_t session, unsigned int sec) +{ int ret; record_parameters_st *params; + if (sec > 0) + session->internals.handshake_endtime = gnutls_time(0) + sec; + else + session->internals.handshake_endtime = 0; + /* sanity check. Verify that there are priorities setup. */ if (session->internals.priorities.protocol.algorithms == 0) |