]> git.ipfire.org Git - thirdparty/gnutls.git/commitdiff
gnutls_transport_set_lowat() is no more.
authorNikos Mavrogiannopoulos <nmav@gnutls.org>
Sat, 12 Mar 2011 10:22:15 +0000 (11:22 +0100)
committerNikos Mavrogiannopoulos <nmav@gnutls.org>
Sat, 12 Mar 2011 10:22:15 +0000 (11:22 +0100)
NEWS
doc/cha-intro-tls.texi
lib/gnutls_buffers.c
lib/gnutls_int.h
lib/gnutls_record.c
lib/gnutls_state.c
lib/includes/gnutls/compat.h
lib/includes/gnutls/gnutls.h.in
lib/libgnutls.map

diff --git a/NEWS b/NEWS
index 94f31db30fd723258a7f4c6993be168d3713166e..a7333f48cc8b19e1be9bce6665b36c1112f8e197 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -5,6 +5,8 @@ See the end for copying conditions.
 
 * Version 2.99.0 (unreleased)
 
+** libgnutls: gnutls_transport_set_lowat() is no more.
+
 ** libgnutls-openssl: modified to use modern gnutls' functions.
 This introduces an ABI incompatibility with previous versions.
 
index 192799fbd22a00ca711753ffa2d0d41658ced96c..c3fa6de374cb96fa0696e9ac43254a7775566461 100644 (file)
@@ -66,7 +66,6 @@ required callbacks to access the transport layer.
 @item @ref{gnutls_transport_set_push_function}
 @item @ref{gnutls_transport_set_pull_function}
 @item @ref{gnutls_transport_set_ptr}
-@item @ref{gnutls_transport_set_lowat}
 @item @ref{gnutls_transport_set_errno}
 @end itemize
 
@@ -89,15 +88,8 @@ again), if any of these error codes is returned.  The error codes
 above refer to the system call, not the @acronym{GnuTLS} function,
 since signals do not interrupt @acronym{GnuTLS}' functions.
 
-For non blocking sockets or other custom made pull/push functions
-the @ref{gnutls_transport_set_lowat} must be called, with a zero
-low water mark value.
-
 By default, if the transport functions are not set, @acronym{GnuTLS}
-will use the Berkeley Sockets functions.  In this case
-@acronym{GnuTLS} will use some hacks in order for @code{select} to
-work, thus making it easy to add @acronym{TLS} support to existing
-TCP/IP servers.
+will use the Berkeley Sockets functions. 
 
 @node The TLS record protocol
 @section The TLS Record Protocol
index 864a7279ec91fb8ad035789e2c2ed11042eb9ef1..c66f1124ad2d4b798dbda2cb22b19cc535159fbd 100644 (file)
@@ -377,45 +377,6 @@ _gnutls_writev (gnutls_session_t session, const giovec_t * giovec,
   return i;
 }
 
-#define RCVLOWAT session->internals.lowat
-
-/* This function is only used with berkeley style sockets.
- * Clears the peeked data (read with MSG_PEEK).
- */
-int
-_gnutls_io_clear_peeked_data (gnutls_session_t session)
-{
-  mbuffer_st *peekdata;
-  int ret, sum;
-
-  if (session->internals.have_peeked_data == 0 || RCVLOWAT == 0)
-    return 0;
-
-  /* this was already read by using MSG_PEEK - so it shouldn't fail */
-  sum = 0;
-  do
-    {                           /* we need this to finish now */
-      ret =
-        _gnutls_read (session, &peekdata, RCVLOWAT - sum,
-                      session->internals.pull_func);
-      if (ret > 0)
-        sum += ret;
-      _mbuffer_xfree (&peekdata);
-    }
-  while (ret == GNUTLS_E_INTERRUPTED || ret == GNUTLS_E_AGAIN
-         || sum < RCVLOWAT);
-
-  if (ret < 0)
-    {
-      gnutls_assert ();
-      return ret;
-    }
-
-  session->internals.have_peeked_data = 0;
-
-  return 0;
-}
-
 /* This function is like recv(with MSG_PEEK). But it does not return -1 on error.
  * It does return gnutls_errno instead.
  * This function reads data from the socket and keeps them in a buffer, of up to
@@ -429,10 +390,10 @@ ssize_t
 _gnutls_io_read_buffered (gnutls_session_t session, size_t total,
                           content_type_t recv_type)
 {
-  ssize_t ret = 0, ret2 = 0;
+  ssize_t ret = 0;
   size_t min;
   mbuffer_st *bufel = NULL;
-  size_t recvlowat, recvdata, readsize;
+  size_t recvdata, readsize;
 
   if (total > MAX_RECV_SIZE(session) || total == 0)
     {
@@ -440,28 +401,6 @@ _gnutls_io_read_buffered (gnutls_session_t session, size_t total,
       return GNUTLS_E_INVALID_REQUEST;
     }
 
-  /* If an external pull function is used, then do not leave
-   * any data into the kernel buffer.
-   */
-  if (session->internals.pull_func != system_read)
-    {
-      recvlowat = 0;
-    }
-  else
-    {
-      /* leave peeked data to the kernel space only if application data
-       * is received and we don't have any peeked 
-       * data in gnutls session.
-       */
-      if (recv_type != GNUTLS_APPLICATION_DATA
-          && session->internals.have_peeked_data == 0)
-        recvlowat = 0;
-      else
-        recvlowat = RCVLOWAT;
-    }
-
-
-
   /* calculate the actual size, ie. get the minimum of the
    * buffered data and the requested data.
    */
@@ -481,7 +420,7 @@ _gnutls_io_read_buffered (gnutls_session_t session, size_t total,
    * receive in order to return the requested data.
    */
   recvdata = total - min;
-  readsize = recvdata - recvlowat;
+  readsize = recvdata;
 
   /* Check if the previously read data plus the new data to
    * receive are longer than the maximum receive buffer size.
@@ -531,50 +470,10 @@ _gnutls_io_read_buffered (gnutls_session_t session, size_t total,
   else
     _mbuffer_xfree (&bufel);
 
-
-  /* This is hack in order for select to work. Just leave recvlowat data,
-   * into the kernel buffer (using a read with MSG_PEEK), thus making
-   * select think, that the socket is ready for reading.
-   * MSG_PEEK is only used with berkeley style sockets.
-   */
-  if (ret == readsize && recvlowat > 0 && !_gnutls_is_dtls(session) && 
-    session->internals.pull_func == system_read)
-    {
-      ret2 = _gnutls_read (session, &bufel, recvlowat, system_read_peek);
-
-      if (ret2 < 0 && gnutls_error_is_fatal (ret2) == 0)
-        {
-          _mbuffer_xfree (&bufel);
-          return ret2;
-        }
-
-      if (ret2 > 0)
-        {
-          _gnutls_read_log ("RB-PEEK: Read %d bytes in PEEK MODE.\n",
-                            (int) ret2);
-          _gnutls_read_log
-            ("RB-PEEK: Have %d bytes into buffer. Adding %d bytes.\nRB: Requested %d bytes\n",
-             (int) session->internals.record_recv_buffer.byte_length,
-             (int) ret2, (int) total);
-          session->internals.have_peeked_data = 1;
-          _mbuffer_enqueue (&session->internals.record_recv_buffer, bufel);
-        }
-      else
-        _mbuffer_xfree (&bufel);
-    }
-
-  if (ret < 0 || ret2 < 0)
+  if (ret < 0)
     {
       gnutls_assert ();
-      /* that's because they are initialized to 0 */
-      return MIN (ret, ret2);
-    }
-
-  ret += ret2;
-
-  if (ret > 0 && ret < recvlowat)
-    {
-      return gnutls_assert_val(GNUTLS_E_AGAIN);
+      return ret;
     }
 
   if (ret == 0)
index 182f3ad65925b938d0e02313d8c33a245a1de328..b4da634ec9f4b8978f3764a138336fb93abf1836 100644 (file)
@@ -127,9 +127,6 @@ typedef struct
   } gnutls_ext_parse_type_t;
 
 
-/* the default for TCP */
-#define DEFAULT_LOWAT 0
-
 /* expire time for resuming sessions */
 #define DEFAULT_EXPIRE_TIME 3600
 
@@ -660,9 +657,6 @@ typedef struct
   security_parameters_st resumed_security_parameters;
   gnutls_compression_method_t resumed_compression_method;
 
-  /* sockets internals */
-  int lowat;
-
   /* These buffers are used in the handshake
    * protocol only. freed using _gnutls_handshake_io_buffer_clear();
    */
@@ -683,11 +677,6 @@ typedef struct
                                          * send.
                                          */
 
-
-  /* 0 if no peeked data was kept, 1 otherwise.
-   */
-  int have_peeked_data:1;
-
   int expire_time;              /* after expire_time seconds this session will expire */
   struct mod_auth_st_int *auth_struct;  /* used in handshake packets and KX algorithms */
 
index 82efe021015d4cb33dad78588d9d7b1c8b8a928c..4c0278fe973c08511428a85d4b1da3ca6f637724 100644 (file)
@@ -69,24 +69,6 @@ _gnutls_set_current_version (gnutls_session_t session,
   session->security_parameters.version = version;
 }
 
-/**
- * gnutls_transport_set_lowat:
- * @session: is a #gnutls_session_t structure.
- * @num: is the low water value.
- *
- * Used to set the lowat value in order for select to check if there
- * are pending data to socket buffer. Used only if you have changed
- * the default low water value (default is 1).  Normally you will not
- * need that function.  This function is only useful if using
- * berkeley style sockets.  Otherwise it must be called and set lowat
- * to zero.
- **/
-void
-gnutls_transport_set_lowat (gnutls_session_t session, int num)
-{
-  session->internals.lowat = num;
-}
-
 /**
  * gnutls_record_disable_padding:
  * @session: is a #gnutls_session_t structure.
@@ -244,7 +226,6 @@ gnutls_bye (gnutls_session_t session, gnutls_close_request_t how)
         {
           do
             {
-              _gnutls_io_clear_peeked_data (session);
               ret = _gnutls_recv_int (session, GNUTLS_ALERT, -1, NULL, 0, NULL);
             }
           while (ret == GNUTLS_E_GOT_APPLICATION_DATA);
@@ -542,7 +523,7 @@ check_buffers (gnutls_session_t session, content_type_t type,
        type == GNUTLS_CHANGE_CIPHER_SPEC)
       && _gnutls_record_buffer_get_size (type, session) > 0)
     {
-      int ret, ret2;
+      int ret;
       ret = _gnutls_record_buffer_get (type, session, data, data_size, seq);
       if (ret < 0)
         {
@@ -550,16 +531,6 @@ check_buffers (gnutls_session_t session, content_type_t type,
           return ret;
         }
 
-      /* if the buffer just got empty */
-      if (_gnutls_record_buffer_get_size (type, session) == 0)
-        {
-          if ((ret2 = _gnutls_io_clear_peeked_data (session)) < 0)
-            {
-              gnutls_assert ();
-              return ret2;
-            }
-        }
-
       return ret;
     }
 
index feaebc87abd8f8e80508a0a572f94ef8959ef2be..b268971cb0515131a006c170f2a8488a4a66b714 100644 (file)
@@ -335,8 +335,6 @@ gnutls_init (gnutls_session_t * session, unsigned int flags)
 
   gnutls_dh_set_prime_bits ((*session), MIN_DH_BITS);
 
-  gnutls_transport_set_lowat ((*session), DEFAULT_LOWAT);       /* the default for tcp */
-
   gnutls_handshake_set_max_packet_length ((*session),
                                           MAX_HANDSHAKE_PACKET_SIZE);
 
index 504e1d674a8e805f7ec4789cb7ddb394aa01a4b0..9399e0b01e76360b066a18cd67a37f1f11433062 100644 (file)
@@ -22,6 +22,9 @@
 /* gnutls_connection_end_t was made redundant in 2.99.0 */
 #define gnutls_connection_end_t unsigned int
 
+/* no longer valid since 2.99.0 */
+#define gnutls_transport_set_lowat(session, num)
+
 /* Stuff deprected in 2.x */
 #define gnutls_cipher_algorithm gnutls_cipher_algorithm_t
 #define gnutls_kx_algorithm gnutls_kx_algorithm_t
index 91a35c4645ab9e3219f363bda51ae75d788dd67c..7e70a33fe0d5b867c64ef988d2bbf8bd6a70d2b7 100644 (file)
@@ -1196,9 +1196,6 @@ extern "C"
                                   gnutls_transport_ptr_t * recv_ptr,
                                   gnutls_transport_ptr_t * send_ptr);
 
-  void gnutls_transport_set_lowat (gnutls_session_t session, int num);
-
-
   void gnutls_transport_set_vec_push_function (gnutls_session_t session,
                                             gnutls_vec_push_func vec_func);
   void gnutls_transport_set_push_function (gnutls_session_t session,
index e5bffe3b17d43b0b4beeb9d5ec18e77837c06d27..b91d291bf98c1b4c12a735d2bba91f3b6ea748a0 100644 (file)
@@ -373,7 +373,6 @@ GNUTLS_1_4
     gnutls_transport_get_ptr;
     gnutls_transport_set_errno;
     gnutls_transport_set_global_errno;
-    gnutls_transport_set_lowat;
     gnutls_transport_set_ptr2;
     gnutls_transport_set_ptr;
     gnutls_transport_set_pull_function;