From: Nikos Mavrogiannopoulos Date: Sat, 12 Mar 2011 10:22:15 +0000 (+0100) Subject: gnutls_transport_set_lowat() is no more. X-Git-Tag: gnutls_2_99_0~137 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=55a1235fcc59736d052250aa5118fbcd896ed244;p=thirdparty%2Fgnutls.git gnutls_transport_set_lowat() is no more. --- diff --git a/NEWS b/NEWS index 94f31db30f..a7333f48cc 100644 --- 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. diff --git a/doc/cha-intro-tls.texi b/doc/cha-intro-tls.texi index 192799fbd2..c3fa6de374 100644 --- a/doc/cha-intro-tls.texi +++ b/doc/cha-intro-tls.texi @@ -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 diff --git a/lib/gnutls_buffers.c b/lib/gnutls_buffers.c index 864a7279ec..c66f1124ad 100644 --- a/lib/gnutls_buffers.c +++ b/lib/gnutls_buffers.c @@ -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) diff --git a/lib/gnutls_int.h b/lib/gnutls_int.h index 182f3ad659..b4da634ec9 100644 --- a/lib/gnutls_int.h +++ b/lib/gnutls_int.h @@ -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 */ diff --git a/lib/gnutls_record.c b/lib/gnutls_record.c index 82efe02101..4c0278fe97 100644 --- a/lib/gnutls_record.c +++ b/lib/gnutls_record.c @@ -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; } diff --git a/lib/gnutls_state.c b/lib/gnutls_state.c index feaebc87ab..b268971cb0 100644 --- a/lib/gnutls_state.c +++ b/lib/gnutls_state.c @@ -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); diff --git a/lib/includes/gnutls/compat.h b/lib/includes/gnutls/compat.h index 504e1d674a..9399e0b01e 100644 --- a/lib/includes/gnutls/compat.h +++ b/lib/includes/gnutls/compat.h @@ -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 diff --git a/lib/includes/gnutls/gnutls.h.in b/lib/includes/gnutls/gnutls.h.in index 91a35c4645..7e70a33fe0 100644 --- a/lib/includes/gnutls/gnutls.h.in +++ b/lib/includes/gnutls/gnutls.h.in @@ -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, diff --git a/lib/libgnutls.map b/lib/libgnutls.map index e5bffe3b17..b91d291bf9 100644 --- a/lib/libgnutls.map +++ b/lib/libgnutls.map @@ -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;