]> git.ipfire.org Git - thirdparty/gnutls.git/commitdiff
Added gnutls_record_set_timeout().
authorNikos Mavrogiannopoulos <nmav@gnutls.org>
Mon, 21 Jan 2013 18:05:29 +0000 (19:05 +0100)
committerNikos Mavrogiannopoulos <nmav@gnutls.org>
Mon, 21 Jan 2013 18:05:29 +0000 (19:05 +0100)
NEWS
lib/gnutls_handshake.c
lib/gnutls_int.h
lib/gnutls_record.c
lib/includes/gnutls/gnutls.h.in

diff --git a/NEWS b/NEWS
index 709e7b48a1ae868099ffb53940733281ebcf0898..3a12ec9558b74d6e1c525ee4669dc9154271cbd5 100644 (file)
--- 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
index 10484b6aaf5a0a5044e76afd370908235d520430..842caf10bc665018c09db01babcf859de2699fac 100644 (file)
@@ -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
index 0841dc28d4d65156c032a23d699ef4ca1ea8c617..972d6b704646400e3b5ea2d8f6cbe7f32eddecc5 100644 (file)
@@ -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;
index 2a5b0ba8b2d61b45abec2037bb0e3cbf9a1eeb00..1501be9ecadcf4ef9cdf903e9e00004eadce9131 100644 (file)
@@ -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;
 }
index 91ada345a3fba535b180aaa0051508a74fd6ab25..ce6538dd3f3e41232f6927f1782ea387019c25bb 100644 (file)
@@ -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,