Replace the incoming message buffer with a ring buffer.

It has size 7. There's no need for a priority queue structure, especially one
that's O(N^2) anyway.

Change-Id: I7609794aac1925c9bbf3015744cae266dcb79bff
Reviewed-on: https://boringssl-review.googlesource.com/8437
Reviewed-by: Adam Langley <agl@google.com>
diff --git a/ssl/d1_lib.c b/ssl/d1_lib.c
index 0c47dc6..d738c57 100644
--- a/ssl/d1_lib.c
+++ b/ssl/d1_lib.c
@@ -97,13 +97,6 @@
   }
   memset(d1, 0, sizeof *d1);
 
-  d1->buffered_messages = pqueue_new();
-  if (d1->buffered_messages == NULL) {
-    OPENSSL_free(d1);
-    ssl3_free(ssl);
-    return 0;
-  }
-
   ssl->d1 = d1;
 
   /* Set the version to the highest supported version.
@@ -115,17 +108,6 @@
   return 1;
 }
 
-static void dtls1_clear_queues(SSL *ssl) {
-  pitem *item = NULL;
-  hm_fragment *frag = NULL;
-
-  while ((item = pqueue_pop(ssl->d1->buffered_messages)) != NULL) {
-    frag = (hm_fragment *)item->data;
-    dtls1_hm_fragment_free(frag);
-    pitem_free(item);
-  }
-}
-
 void dtls1_free(SSL *ssl) {
   ssl3_free(ssl);
 
@@ -133,9 +115,7 @@
     return;
   }
 
-  dtls1_clear_queues(ssl);
-  pqueue_free(ssl->d1->buffered_messages);
-
+  dtls_clear_incoming_messages(ssl);
   dtls_clear_outgoing_messages(ssl);
 
   OPENSSL_free(ssl->d1);