gnutls-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[SCM] GNU gnutls branch, master, updated. gnutls-3_0_12-163-gaed50df


From: Nikos Mavrogiannopoulos
Subject: [SCM] GNU gnutls branch, master, updated. gnutls-3_0_12-163-gaed50df
Date: Wed, 08 Feb 2012 22:48:31 +0000

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GNU gnutls".

http://git.savannah.gnu.org/cgit/gnutls.git/commit/?id=aed50df9cb6026864a0eabc36af9b3b9b22a0763

The branch, master has been updated
       via  aed50df9cb6026864a0eabc36af9b3b9b22a0763 (commit)
       via  8c19b028492148fcd27c2472a56cb46b88e5eea2 (commit)
       via  da7ed7be8266fe7c478533342aea4a9bdb651d5d (commit)
      from  44eeb40c0fddff712223c62440f7320566061380 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit aed50df9cb6026864a0eabc36af9b3b9b22a0763
Author: Nikos Mavrogiannopoulos <address@hidden>
Date:   Wed Feb 8 23:46:11 2012 +0100

    tests print server or client side in debugging output.

commit 8c19b028492148fcd27c2472a56cb46b88e5eea2
Author: Nikos Mavrogiannopoulos <address@hidden>
Date:   Wed Feb 8 23:44:13 2012 +0100

    gnutls_record_check_pending() accounts data not yet processed.
    DTLS layer avoids multiple retransmissions in non-blocking mode.

commit da7ed7be8266fe7c478533342aea4a9bdb651d5d
Author: Nikos Mavrogiannopoulos <address@hidden>
Date:   Wed Feb 8 22:04:20 2012 +0100

    avoid many allocations for transmitting DTLS packets.

-----------------------------------------------------------------------

Summary of changes:
 lib/gnutls_buffers.c          |    2 +-
 lib/gnutls_buffers.h          |    2 +-
 lib/gnutls_dtls.c             |   79 +++++++++++++++++++++++++++--------------
 lib/gnutls_handshake.c        |    6 ++-
 lib/gnutls_int.h              |    3 +-
 lib/gnutls_record.c           |    4 +-
 tests/eagain-common.h         |   14 ++++++--
 tests/mini-deflate.c          |    4 ++-
 tests/mini-eagain-dtls.c      |    4 ++-
 tests/mini-eagain.c           |    4 ++-
 tests/mini-x509-rehandshake.c |    4 ++-
 tests/mini-x509.c             |    4 ++-
 tests/mini.c                  |    4 ++-
 13 files changed, 91 insertions(+), 43 deletions(-)

diff --git a/lib/gnutls_buffers.c b/lib/gnutls_buffers.c
index b896c1a..755bb4c 100644
--- a/lib/gnutls_buffers.c
+++ b/lib/gnutls_buffers.c
@@ -93,7 +93,7 @@ _gnutls_record_buffer_put (gnutls_session_t session,
 size_t
 gnutls_record_check_pending (gnutls_session_t session)
 {
-  return _gnutls_record_buffer_get_size (GNUTLS_APPLICATION_DATA, session);
+  return _gnutls_record_buffer_get_size (session) + 
session->internals.record_recv_buffer.byte_length;
 }
 
 int
diff --git a/lib/gnutls_buffers.h b/lib/gnutls_buffers.h
index 92b758a..8a738b2 100644
--- a/lib/gnutls_buffers.h
+++ b/lib/gnutls_buffers.h
@@ -29,7 +29,7 @@ _gnutls_record_buffer_put (gnutls_session_t session,
   content_type_t type, uint64* seq, mbuffer_st* bufel);
 
 inline static int
-_gnutls_record_buffer_get_size (content_type_t type, gnutls_session_t session)
+_gnutls_record_buffer_get_size (gnutls_session_t session)
 {
   return session->internals.record_buffer.byte_length;
 }
diff --git a/lib/gnutls_dtls.c b/lib/gnutls_dtls.c
index e6cf0e4..f6dcfac 100644
--- a/lib/gnutls_dtls.c
+++ b/lib/gnutls_dtls.c
@@ -37,10 +37,12 @@
 
 
 /* This function fragments and transmits a previously buffered
- * outgoing message. */
+ * outgoing message. It accepts mtu_data which is a buffer to
+ * be reused (should be set to NULL initially).
+ */
 static inline int
 transmit_message (gnutls_session_t session,
-                 mbuffer_st *bufel)
+                 mbuffer_st *bufel, uint8_t **buf)
 {
   uint8_t *data, *mtu_data;
   int ret = 0;
@@ -60,10 +62,12 @@ transmit_message (gnutls_session_t session,
         _mbuffer_get_uhead_size(bufel), 0);
     }
 
-  mtu_data = gnutls_malloc(mtu + DTLS_HANDSHAKE_HEADER_SIZE);
-  if (mtu_data == NULL)
+  *buf = gnutls_realloc_fast(*buf, mtu + DTLS_HANDSHAKE_HEADER_SIZE);
+  if (*buf == NULL)
     return gnutls_assert_val(GNUTLS_E_MEMORY_ERROR);
 
+  mtu_data = *buf;
+
   data = _mbuffer_get_udata_ptr( bufel);
   data_size = _mbuffer_get_udata_size(bufel);
 
@@ -111,8 +115,6 @@ transmit_message (gnutls_session_t session,
         }
    }
 
-  gnutls_free (mtu_data);
-
   return ret;
 }
 
@@ -142,11 +144,13 @@ static int drop_usage_count(gnutls_session_t session, 
mbuffer_head_st *const sen
 int _dtls_retransmit(gnutls_session_t session)
 {
 time_t now = gnutls_time (0);
+int ret;
 
   if (now - session->internals.dtls.last_retransmit > RETRANSMIT_WINDOW)
     {
+      ret = _dtls_transmit(session);
       session->internals.dtls.last_retransmit = now;
-      return _dtls_transmit(session);
+      return ret;
     }
   else
     return 0;
@@ -167,6 +171,7 @@ int
 _dtls_transmit (gnutls_session_t session)
 {
 int ret;
+uint8_t* buf = NULL;
 
   /* PREPARING -> SENDING state transition */
   mbuffer_head_st *const send_buffer =
@@ -215,32 +220,50 @@ int ret;
           ret = gnutls_assert_val(GNUTLS_E_TIMEDOUT);
           goto cleanup;
         }
+        
+      if ((session->internals.dtls.flight_init == 0) ||
+          (now - session->internals.dtls.last_retransmit > RETRANSMIT_WINDOW))
+        {
+          session->internals.dtls.last_retransmit = now;
 
-      _gnutls_dtls_log ("DTLS[%p]: %sStart of flight transmission.\n", 
session,  (session->internals.dtls.flight_init == 0)?"":"re-");
+          _gnutls_dtls_log ("DTLS[%p]: %sStart of flight transmission.\n", 
session,  (session->internals.dtls.flight_init == 0)?"":"re-");
 
-      for (cur = send_buffer->head;
-           cur != NULL; cur = cur->next)
-        {
-          transmit_message (session, cur);
-          last_type = cur->htype;
-        }
+          for (cur = send_buffer->head;
+               cur != NULL; cur = cur->next)
+            {
+              ret = transmit_message (session, cur, &buf);
+              if (ret < 0)
+                {
+                  gnutls_assert();
+                  goto cleanup;
+                }
 
-      if (session->internals.dtls.flight_init == 0)
-        {
-          session->internals.dtls.flight_init = 1;
-          session->internals.dtls.handshake_last_call = now;
-          session->internals.dtls.actual_retrans_timeout_ms = 
session->internals.dtls.retrans_timeout_ms;
+              last_type = cur->htype;
+            }
 
-          if (last_type == GNUTLS_HANDSHAKE_FINISHED)
+          if (buf != NULL)
             {
-              /* On the last flight we cannot ensure retransmission
-               * from here. _dtls_wait_and_retransmit() is being called
-               * by handshake.
-               */
-              session->internals.dtls.last_flight = 1;
+              gnutls_free(buf);
+              buf = NULL;
             }
-          else
-            session->internals.dtls.last_flight = 0;
+
+          if (session->internals.dtls.flight_init == 0)
+            {
+              session->internals.dtls.flight_init = 1;
+              session->internals.dtls.handshake_last_call = now;
+              session->internals.dtls.actual_retrans_timeout_ms = 
session->internals.dtls.retrans_timeout_ms;
+
+              if (last_type == GNUTLS_HANDSHAKE_FINISHED)
+                {
+                  /* On the last flight we cannot ensure retransmission
+                   * from here. _dtls_wait_and_retransmit() is being called
+                   * by handshake.
+                   */
+                  session->internals.dtls.last_flight = 1;
+                }
+              else
+                session->internals.dtls.last_flight = 0;
+           }
         }
 
       ret = _gnutls_io_write_flush (session);
@@ -285,6 +308,8 @@ int ret;
   ret = 0;
 
 cleanup:
+  if (buf != NULL)
+    gnutls_free(buf);
   _gnutls_dtls_log ("DTLS[%p]: End of flight transmission.\n", session);
 
   session->internals.dtls.flight_init = 0;
diff --git a/lib/gnutls_handshake.c b/lib/gnutls_handshake.c
index f362be8..60434fa 100644
--- a/lib/gnutls_handshake.c
+++ b/lib/gnutls_handshake.c
@@ -2680,7 +2680,8 @@ _gnutls_recv_handshake_final (gnutls_session_t session, 
int init)
       /* This is the last flight and peer cannot be sure
        * we have received it unless we notify him. So we
        * wait for a message and retransmit if needed. */
-      if (IS_DTLS(session) && !_dtls_is_async(session))
+      if (IS_DTLS(session) && !_dtls_is_async(session) && 
+          gnutls_record_check_pending (session) == 0)
         {
           ret = _dtls_wait_and_retransmit(session);
           if (ret < 0)
@@ -2716,7 +2717,8 @@ _gnutls_recv_handshake_final (gnutls_session_t session, 
int init)
     case STATE31:
       STATE = STATE31;
 
-       if (IS_DTLS(session) && !_dtls_is_async(session))
+       if (IS_DTLS(session) && !_dtls_is_async(session) && 
+           gnutls_record_check_pending( session) == 0)
          {
            ret = _dtls_wait_and_retransmit(session);
            if (ret < 0)
diff --git a/lib/gnutls_int.h b/lib/gnutls_int.h
index 7f3c676..d993544 100644
--- a/lib/gnutls_int.h
+++ b/lib/gnutls_int.h
@@ -701,7 +701,8 @@ typedef struct
   /* this buffer holds a record packet -mostly used for
    * non blocking IO.
    */
-  mbuffer_head_st record_recv_buffer;   /* buffer holding the record that is 
currently being received */
+  mbuffer_head_st record_recv_buffer;   /* buffer holding the record that is 
currently 
+                                         * being received */
   mbuffer_head_st record_send_buffer;   /* holds cached data
                                          * for the gnutls_io_write_buffered()
                                          * function.
diff --git a/lib/gnutls_record.c b/lib/gnutls_record.c
index 963966f..460db36 100644
--- a/lib/gnutls_record.c
+++ b/lib/gnutls_record.c
@@ -493,7 +493,7 @@ check_buffers (gnutls_session_t session, content_type_t 
type,
   if ((type == GNUTLS_APPLICATION_DATA ||
        type == GNUTLS_HANDSHAKE ||
        type == GNUTLS_CHANGE_CIPHER_SPEC)
-      && _gnutls_record_buffer_get_size (type, session) > 0)
+      && _gnutls_record_buffer_get_size (session) > 0)
     {
       int ret;
       ret = _gnutls_record_buffer_get (type, session, data, data_size, seq);
@@ -906,7 +906,7 @@ gnutls_datum_t raw; /* raw headers */
  */
 ssize_t
 _gnutls_recv_in_buffers (gnutls_session_t session, content_type_t type,
-                  gnutls_handshake_description_t htype)
+                         gnutls_handshake_description_t htype)
 {
   uint64 *packet_sequence;
   uint8_t *ciphertext;
diff --git a/tests/eagain-common.h b/tests/eagain-common.h
index 07d5148..7c21836 100644
--- a/tests/eagain-common.h
+++ b/tests/eagain-common.h
@@ -1,5 +1,6 @@
 #define min(x,y) ((x)<(y)?(x):(y))
-//#define EAGAIN_DEBUG
+
+extern const char* side;
 
 #define HANDSHAKE_EXPECT(c, s, clierr, serverr) \
   sret = cret = GNUTLS_E_AGAIN; \
@@ -7,10 +8,12 @@
     { \
       if (cret == GNUTLS_E_AGAIN) \
         { \
+          side = "client"; \
           cret = gnutls_handshake (c); \
         } \
       if (sret == GNUTLS_E_AGAIN) \
         { \
+          side = "server"; \
           sret = gnutls_handshake (s); \
         } \
     } \
@@ -29,6 +32,7 @@
 #define TRANSFER(c, s, msg, msglen, buf, buflen) \
   do \
     { \
+      side = "client"; \
       ret = gnutls_record_send (c, msg, msglen); \
     } \
   while(ret == GNUTLS_E_AGAIN); \
@@ -39,6 +43,7 @@
     { \
       do \
         { \
+          side = "server"; \
           ret = gnutls_record_recv (s, buf, buflen); \
         } \
       while(ret == GNUTLS_E_AGAIN); \
@@ -54,12 +59,14 @@
         } \
       do \
         { \
+          side = "server"; \
           ns = gnutls_record_send (server, msg, msglen); \
         } \
       while (ns == GNUTLS_E_AGAIN); \
       if (ns < 0) fail ("server send error: %s\n", gnutls_strerror (ret)); \
       do \
         { \
+          side = "client"; \
           ret = gnutls_record_recv (client, buf, buflen); \
         } \
       while(ret == GNUTLS_E_AGAIN); \
@@ -82,6 +89,7 @@
           /* echo back */ \
           do \
             { \
+              side = "client"; \
               ns = gnutls_record_send (client, buf, msglen); \
             } \
           while (ns == GNUTLS_E_AGAIN); \
@@ -212,7 +220,7 @@ int ret;
     ret = 0; /* timeout */
 
 #ifdef EAGAIN_DEBUG
-  fprintf(stderr, "eagain: server_pull_timeout: %d\n", ret);
+  fprintf(stderr, "eagain: server_pull_timeout: %d (avail: cli %d, serv 
%d)\n", ret, (int)to_client_len, (int)to_server_len);
 #endif
 
   return ret;
@@ -228,7 +236,7 @@ int ret;
     ret = 0;
 
 #ifdef EAGAIN_DEBUG
-  fprintf(stderr, "eagain: client_pull_timeout: %d\n", ret);
+  fprintf(stderr, "eagain: client_pull_timeout: %d (avail: cli %d, serv 
%d)\n", ret, (int)to_client_len, (int)to_server_len);
 #endif
 
   return ret;
diff --git a/tests/mini-deflate.c b/tests/mini-deflate.c
index 40a2ea9..674338c 100644
--- a/tests/mini-deflate.c
+++ b/tests/mini-deflate.c
@@ -35,10 +35,12 @@
 # include "eagain-common.h"
 # include "utils.h"
 
+const char* side = "";
+
 static void
 tls_log_func (int level, const char *str)
 {
-  fprintf (stderr, "|<%d>| %s", level, str);
+  fprintf (stderr, "%s|<%d>| %s", side, level, str);
 }
 
 # define MAX_BUF 6*1024
diff --git a/tests/mini-eagain-dtls.c b/tests/mini-eagain-dtls.c
index aeb2f44..f6f65e9 100644
--- a/tests/mini-eagain-dtls.c
+++ b/tests/mini-eagain-dtls.c
@@ -34,10 +34,12 @@
 #define RANDOMIZE
 #include "eagain-common.h"
 
+const char* side = "";
+
 static void
 tls_log_func (int level, const char *str)
 {
-  fprintf (stderr, "|<%d>| %s", level, str);
+  fprintf (stderr, "%s|<%d>| %s", side, level, str);
 }
 
 static int handshake = 0;
diff --git a/tests/mini-eagain.c b/tests/mini-eagain.c
index 3aa1748..ac25ffb 100644
--- a/tests/mini-eagain.c
+++ b/tests/mini-eagain.c
@@ -35,10 +35,12 @@
 #define RANDOMIZE
 #include "eagain-common.h"
 
+const char* side = "";
+
 static void
 tls_log_func (int level, const char *str)
 {
-  fprintf (stderr, "|<%d>| %s", level, str);
+  fprintf (stderr, "%s|<%d>| %s", side, level, str);
 }
 
 static int handshake = 0;
diff --git a/tests/mini-x509-rehandshake.c b/tests/mini-x509-rehandshake.c
index 090ab8d..afad1bf 100644
--- a/tests/mini-x509-rehandshake.c
+++ b/tests/mini-x509-rehandshake.c
@@ -32,10 +32,12 @@
 #include "utils.h"
 #include "eagain-common.h"
 
+const char* side;
+
 static void
 tls_log_func (int level, const char *str)
 {
-  fprintf (stderr, "|<%d>| %s", level, str);
+  fprintf (stderr, "%s|<%d>| %s", side, level, str);
 }
 
 static unsigned char server_cert_pem[] =
diff --git a/tests/mini-x509.c b/tests/mini-x509.c
index dac5a5a..5b58147 100644
--- a/tests/mini-x509.c
+++ b/tests/mini-x509.c
@@ -32,10 +32,12 @@
 #include "utils.h"
 #include "eagain-common.h"
 
+const char* side;
+
 static void
 tls_log_func (int level, const char *str)
 {
-  fprintf (stderr, "|<%d>| %s", level, str);
+  fprintf (stderr, "%s|<%d>| %s", side, level, str);
 }
 
 static unsigned char server_cert_pem[] =
diff --git a/tests/mini.c b/tests/mini.c
index eec1bcf..fa0b37b 100644
--- a/tests/mini.c
+++ b/tests/mini.c
@@ -33,10 +33,12 @@
 
 #include "utils.h"
 
+const char* side = "";
+
 static void
 tls_log_func (int level, const char *str)
 {
-  fprintf (stderr, "|<%d>| %s", level, str);
+  fprintf (stderr, "%s|<%d>| %s", side, level, str);
 }
 
 #define MAX_BUF 1024


hooks/post-receive
-- 
GNU gnutls



reply via email to

[Prev in Thread] Current Thread [Next in Thread]