summaryrefslogtreecommitdiff
path: root/ssl
diff options
context:
space:
mode:
authorMatt Caswell <matt@openssl.org>2024-08-06 10:05:06 +0100
committerTomas Mraz <tomas@openssl.org>2024-08-07 19:48:26 +0200
commitc0c4e6ba0af309371cb7eb2a9f910829a8c01a70 (patch)
treecd7ad30bd89f46ea7be1fc4ea1fff9512097e1d6 /ssl
parente70e34d857d4003199bcb5d3b52ca8102ccc1b98 (diff)
Remove the event queue code
PR #18345 added some code for an event queue. It also added a test for it. Unfortunately this event queue code has never been used for anything. Additionally the test was never integrated into a test recipe, so it never actually gets invoked via "make test". This makes the code entirely dead, unnecessarily bloats the size of libssl and causes a decrease in our testing code coverage value. We remove the dead code. Reviewed-by: Neil Horman <nhorman@openssl.org> Reviewed-by: Tomas Mraz <tomas@openssl.org> (Merged from https://github.com/openssl/openssl/pull/25100)
Diffstat (limited to 'ssl')
-rw-r--r--ssl/build.info2
-rw-r--r--ssl/event_queue.c196
2 files changed, 1 insertions, 197 deletions
diff --git a/ssl/build.info b/ssl/build.info
index de28a0700a..adfc966379 100644
--- a/ssl/build.info
+++ b/ssl/build.info
@@ -32,5 +32,5 @@ IF[{- !$disabled{'deprecated-3.0'} -}]
ENDIF
IF[{- !$disabled{quic} -}]
- SOURCE[../libssl]=priority_queue.c event_queue.c
+ SOURCE[../libssl]=priority_queue.c
ENDIF
diff --git a/ssl/event_queue.c b/ssl/event_queue.c
deleted file mode 100644
index 50b38de4cd..0000000000
--- a/ssl/event_queue.c
+++ /dev/null
@@ -1,196 +0,0 @@
-/*
- * Copyright 2022-2023 The OpenSSL Project Authors. All Rights Reserved.
- *
- * Licensed under the Apache License 2.0 (the "License"). You may not use
- * this file except in compliance with the License. You can obtain a copy
- * in the file LICENSE in the source distribution or at
- * https://www.openssl.org/source/license.html
- */
-
-#include <stdlib.h>
-#include "internal/event_queue.h"
-#include "ssl_local.h"
-
-struct ossl_event_queue_st {
- PRIORITY_QUEUE_OF(OSSL_EVENT) *timed_events;
- PRIORITY_QUEUE_OF(OSSL_EVENT) *now_events;
-};
-
-static int event_compare_times(const OSSL_EVENT *a, const OSSL_EVENT *b)
-{
- return ossl_time_compare(a->when, b->when);
-}
-
-static int event_compare_priority(const OSSL_EVENT *a, const OSSL_EVENT *b)
-{
- if (a->priority > b->priority)
- return -1;
- if (a->priority < b->priority)
- return 1;
- return 0;
-}
-
-OSSL_EVENT_QUEUE *ossl_event_queue_new(void)
-{
- OSSL_EVENT_QUEUE *r = OPENSSL_malloc(sizeof(*r));
-
- if (r != NULL) {
- r->timed_events = ossl_pqueue_OSSL_EVENT_new(&event_compare_times);
- r->now_events = ossl_pqueue_OSSL_EVENT_new(&event_compare_priority);
- if (r->timed_events == NULL || r->now_events == NULL) {
- ossl_event_queue_free(r);
- return NULL;
- }
- }
- return r;
-}
-
-void ossl_event_free(OSSL_EVENT *event)
-{
- if (event != NULL) {
- if (event->flag_dynamic)
- OPENSSL_free(event);
- else
- event->queue = NULL;
- }
-}
-
-static void event_queue_free(PRIORITY_QUEUE_OF(OSSL_EVENT) *queue)
-{
- OSSL_EVENT *e;
-
- if (queue != NULL) {
- while ((e = ossl_pqueue_OSSL_EVENT_pop(queue)) != NULL)
- ossl_event_free(e);
- ossl_pqueue_OSSL_EVENT_free(queue);
- }
-}
-
-void ossl_event_queue_free(OSSL_EVENT_QUEUE *queue)
-{
- if (queue != NULL) {
- event_queue_free(queue->now_events);
- event_queue_free(queue->timed_events);
- OPENSSL_free(queue);
- }
-}
-
-static ossl_inline
-int event_queue_add(OSSL_EVENT_QUEUE *queue, OSSL_EVENT *event)
-{
- PRIORITY_QUEUE_OF(OSSL_EVENT) *pq =
- ossl_time_compare(event->when, ossl_time_now()) <= 0
- ? queue->now_events
- : queue->timed_events;
-
- if (ossl_pqueue_OSSL_EVENT_push(pq, event, &event->ref)) {
- event->queue = pq;
- return 1;
- }
- return 0;
-}
-
-static ossl_inline
-void ossl_event_set(OSSL_EVENT *event, uint32_t type, uint32_t priority,
- OSSL_TIME when, void *ctx,
- void *payload, size_t payload_size)
-{
- event->type = type;
- event->priority = priority;
- event->when = when;
- event->ctx = ctx;
- event->payload = payload;
- event->payload_size = payload_size;
-}
-
-OSSL_EVENT *ossl_event_queue_add_new(OSSL_EVENT_QUEUE *queue,
- uint32_t type, uint32_t priority,
- OSSL_TIME when, void *ctx,
- void *payload, size_t payload_size)
-{
- OSSL_EVENT *e = OPENSSL_malloc(sizeof(*e));
-
- if (e == NULL || queue == NULL) {
- OPENSSL_free(e);
- return NULL;
- }
-
- ossl_event_set(e, type, priority, when, ctx, payload, payload_size);
- e->flag_dynamic = 1;
- if (event_queue_add(queue, e))
- return e;
- OPENSSL_free(e);
- return NULL;
-}
-
-int ossl_event_queue_add(OSSL_EVENT_QUEUE *queue, OSSL_EVENT *event,
- uint32_t type, uint32_t priority,
- OSSL_TIME when, void *ctx,
- void *payload, size_t payload_size)
-{
- if (event == NULL || queue == NULL)
- return 0;
- ossl_event_set(event, type, priority, when, ctx, payload, payload_size);
- event->flag_dynamic = 0;
- return event_queue_add(queue, event);
-}
-
-int ossl_event_queue_remove(OSSL_EVENT_QUEUE *queue, OSSL_EVENT *event)
-{
- if (event != NULL && event->queue != NULL) {
- ossl_pqueue_OSSL_EVENT_remove(event->queue, event->ref);
- event->queue = NULL;
- }
- return 1;
-}
-
-OSSL_TIME ossl_event_time_until(const OSSL_EVENT *event)
-{
- if (event == NULL)
- return ossl_time_infinite();
- return ossl_time_subtract(event->when, ossl_time_now());
-}
-
-OSSL_TIME ossl_event_queue_time_until_next(const OSSL_EVENT_QUEUE *queue)
-{
- if (queue == NULL)
- return ossl_time_infinite();
- if (ossl_pqueue_OSSL_EVENT_num(queue->now_events) > 0)
- return ossl_time_zero();
- return ossl_event_time_until(ossl_pqueue_OSSL_EVENT_peek(queue->timed_events));
-}
-
-int ossl_event_queue_postpone_until(OSSL_EVENT_QUEUE *queue,
- OSSL_EVENT *event,
- OSSL_TIME when)
-{
- if (ossl_event_queue_remove(queue, event)) {
- event->when = when;
- return event_queue_add(queue, event);
- }
- return 0;
-}
-
-int ossl_event_queue_get1_next_event(OSSL_EVENT_QUEUE *queue,
- OSSL_EVENT **event)
-{
- OSSL_TIME now = ossl_time_now();
- OSSL_EVENT *e;
-
- /* Check for expired timer based events and convert them to now events */
- while ((e = ossl_pqueue_OSSL_EVENT_peek(queue->timed_events)) != NULL
- && ossl_time_compare(e->when, now) <= 0) {
- e = ossl_pqueue_OSSL_EVENT_pop(queue->timed_events);
- if (!ossl_pqueue_OSSL_EVENT_push(queue->now_events, e, &e->ref)) {
- e->queue = NULL;
- return 0;
- }
- }
-
- /*
- * Get next event from the now queue.
- * The pop returns NULL when there is none.
- */
- *event = ossl_pqueue_OSSL_EVENT_pop(queue->now_events);
- return 1;
-}