From: Nikos Mavrogiannopoulos Date: Mon, 21 Jan 2013 18:05:29 +0000 (+0100) Subject: Added gnutls_record_set_timeout(). X-Git-Tag: gnutls_3_1_7~92 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=1e8f5a67debebb0f918660bf34fedebc43b1ef36;p=thirdparty%2Fgnutls.git Added gnutls_record_set_timeout(). --- diff --git a/NEWS b/NEWS index 709e7b48a1..3a12ec9558 100644 --- a/NEWS +++ b/NEWS @@ -25,6 +25,7 @@ extension. Its status can be checked using gnutls_record_get_random_padding_stat ** libgnutls-dane: Added function to specify a DLV file. ** API and ABI modifications: +gnutls_record_set_timeout: Added gnutls_record_get_random_padding_status: Added gnutls_sbuf_deinit: Added gnutls_sbuf_init: Added diff --git a/lib/gnutls_handshake.c b/lib/gnutls_handshake.c index 10484b6aaf..842caf10bc 100644 --- a/lib/gnutls_handshake.c +++ b/lib/gnutls_handshake.c @@ -2446,7 +2446,8 @@ gnutls_handshake (gnutls_session_t session) * timeout. * * Note that in order for the timeout to be enforced - * gnutls_transport_set_pull_timeout_function() must be set. + * gnutls_transport_set_pull_timeout_function() must be set + * (it is set by default in most systems). * **/ void diff --git a/lib/gnutls_int.h b/lib/gnutls_int.h index 0841dc28d4..972d6b7046 100644 --- a/lib/gnutls_int.h +++ b/lib/gnutls_int.h @@ -916,6 +916,7 @@ typedef struct time_t handshake_endtime; /* end time in seconds */ unsigned int handshake_timeout_ms; /* timeout in milliseconds */ + unsigned int record_timeout_ms; /* timeout in milliseconds */ gnutls_buffer_st hb_local_data; gnutls_buffer_st hb_remote_data; diff --git a/lib/gnutls_record.c b/lib/gnutls_record.c index 2a5b0ba8b2..1501be9eca 100644 --- a/lib/gnutls_record.c +++ b/lib/gnutls_record.c @@ -1,6 +1,6 @@ /* - * Copyright (C) 2000-2012 Free Software Foundation, Inc. - * Copyright (C) 2012 Nikos Mavrogiannopoulos + * Copyright (C) 2000-2013 Free Software Foundation, Inc. + * Copyright (C) 2012,2013 Nikos Mavrogiannopoulos * * Author: Nikos Mavrogiannopoulos * @@ -221,7 +221,8 @@ gnutls_bye (gnutls_session_t session, gnutls_close_request_t how) { do { - ret = _gnutls_recv_int (session, GNUTLS_ALERT, -1, NULL, 0, NULL, 0); + ret = _gnutls_recv_int (session, GNUTLS_ALERT, -1, NULL, 0, NULL, + session->internals.record_timeout_ms); } while (ret == GNUTLS_E_GOT_APPLICATION_DATA); @@ -1313,7 +1314,8 @@ gnutls_record_send (gnutls_session_t session, const void *data, ssize_t gnutls_record_recv (gnutls_session_t session, void *data, size_t data_size) { - return _gnutls_recv_int (session, GNUTLS_APPLICATION_DATA, -1, data, data_size, NULL, 0); + return _gnutls_recv_int (session, GNUTLS_APPLICATION_DATA, -1, data, data_size, + NULL, session->internals.record_timeout_ms); } /** @@ -1341,5 +1343,27 @@ gnutls_record_recv_seq (gnutls_session_t session, void *data, size_t data_size, unsigned char *seq) { return _gnutls_recv_int (session, GNUTLS_APPLICATION_DATA, -1, data, - data_size, seq, 0); + data_size, seq, session->internals.record_timeout_ms); +} + +/** + * gnutls_record_set_timeout: + * @session: is a #gnutls_session_t structure. + * @ms: is a timeout value in milliseconds + * + * This function sets the receive timeout for the record layer + * to the provided value. Use an @ms value of zero to disable + * timeout (the default). + * + * Note that in order for the timeout to be enforced + * gnutls_transport_set_pull_timeout_function() must be set + * (it is set by default in most systems). + * + * Since: 3.1.7 + * + **/ +void +gnutls_record_set_timeout (gnutls_session_t session, unsigned int ms) +{ + session->internals.record_timeout_ms = ms; } diff --git a/lib/includes/gnutls/gnutls.h.in b/lib/includes/gnutls/gnutls.h.in index 91ada345a3..ce6538dd3f 100644 --- a/lib/includes/gnutls/gnutls.h.in +++ b/lib/includes/gnutls/gnutls.h.in @@ -883,6 +883,7 @@ gnutls_ecc_curve_t gnutls_ecc_curve_get(gnutls_session_t session); unsigned int max_tries, unsigned int flags); int gnutls_heartbeat_pong (gnutls_session_t session, unsigned int flags); + void gnutls_record_set_timeout (gnutls_session_t session, unsigned int ms); ssize_t gnutls_record_send (gnutls_session_t session, const void *data, size_t data_size); ssize_t gnutls_record_recv (gnutls_session_t session, void *data,