summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--doc/internal/man3/OSSL_EVENT.pod201
-rw-r--r--include/internal/event_queue.h163
-rw-r--r--ssl/build.info2
-rw-r--r--ssl/event_queue.c196
-rw-r--r--test/build.info6
-rw-r--r--test/event_queue_test.c112
6 files changed, 2 insertions, 678 deletions
diff --git a/doc/internal/man3/OSSL_EVENT.pod b/doc/internal/man3/OSSL_EVENT.pod
deleted file mode 100644
index fb3e937ea8..0000000000
--- a/doc/internal/man3/OSSL_EVENT.pod
+++ /dev/null
@@ -1,201 +0,0 @@
-=pod
-
-=head1 NAME
-
-OSSL_EVENT_QUEUE, OSSL_EVENT, OSSL_EVENT_SUBSCRIPTION, ossl_event_callback_fn,
-ossl_event_queue_add, ossl_event_queue_add_new, ossl_event_free,
-ossl_event_get_type, ossl_event_get_priority, ossl_event_get_when,
-ossl_event_get0_payload,
-ossl_event_queue_new, ossl_event_queue_free,
-ossl_event_queue_schedule, ossl_event_queue_delete,
-ossl_event_time_until, ossl_event_queue_time_until_next,
-ossl_event_queue_postpone_until,
-ossl_event_queue_get1_next_event
-- event and timer queue
-
-=head1 SYNOPSIS
-
- #include "internal/event_queue.h"
-
- typedef OSSL_EVENT;
- typedef OSSL_EVENT_QUEUE;
- typedef OSSL_EVENT_SUBSCRIPTION;
-
- typedef int ossl_event_callback_fn(OSSL_EVENT *event, void *callback_data);
-
- OSSL_EVENT_QUEUE *ossl_event_queue_new(void);
- void ossl_event_queue_free(OSSL_EVENT_QUEUE *queue);
-
- 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);
- 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);
- void ossl_event_free(OSSL_EVENT *event);
-
- uint32_t ossl_event_get_type(const OSSL_EVENT *event);
- uint32_t ossl_event_get_priority(const OSSL_EVENT *event);
- OSSL_TIME ossl_event_get_when(const OSSL_EVENT *event);
- void *ossl_event_get0_payload(const OSSL_EVENT *event, size_t *length);
-
- int ossl_event_queue_schedule(OSSL_EVENT_QUEUE *queue, OSSL_EVENT *event);
- int ossl_event_queue_delete(OSSL_EVENT_QUEUE *queue, OSSL_EVENT *event);
-
- OSSL_TIME ossl_event_time_until(OSSL_EVENT *event);
- OSSL_TIME ossl_event_queue_time_until_next(const OSSL_EVENT_QUEUE *queue);
-
- int ossl_event_queue_postpone_until(OSSL_EVENT_QUEUE *queue,
- OSSL_EVENT *event,
- OSSL_TIME when);
-
- int ossl_event_queue_get1_next_event(OSSL_EVENT_QUEUE *queue,
- OSSL_EVENT **event);
-
-=head1 DESCRIPTION
-
-These functions implement an event queue.
-
-=head2 Event
-
-An event is a small structure, B<OSSL_EVENT>, carrying information:
-
-=over 4
-
-=item type
-
-A mandatory event type, which is a simple numeric identity, the
-meaning of which is not known by the event functionality itself.
-
-=item priority
-
-A mandatory nonnegative integral quantity. The lower the priority the earlier
-the event will be processed.
-
-=item when
-
-An optional time indicating when the event could be triggered. Events are
-guaranteed to not trigger before their time.
-
-=item context
-
-A reference to user supplied contextual information. The event queue passes
-this to callbacks and never dereferences the pointer.
-
-=item payload, payload_size
-
-A reference to some event specific data of a specified length.
-
-=back
-
-The event itself is designed for a single synchronous thread, i.e. cannot be
-shared by multiple threads. The diverse objects it refers to may, however,
-be shared by multiple threads, at the discretion of the functions in the
-method structure.
-
-Once populated, the event type, the references to event context, and the
-reference to the destructor function are considered immutable, up until the
-event structure is destroyed.
-
-The reference to the auxiliary identifying material or to the payload,
-however, are considered mutable. Any event handler may "steal" them and
-replace the reference to them in the event structure with NULL. Stealing
-must be done with much care.
-
-Events may be embedded in another structure or as a static variable.
-Events may also be dynamically allocated.
-
-B<ossl_event_queue_add> initialises/reinitialises a static event object
-with the specified parameters and adds it to the event queue I<queue>.
-The event object I<event> has it's fields set to the passed parameters.
-
-B<ossl_event_queue_add_new> allocates a new timer event on the heap
-and initialises and adds it as per B<ossl_event_queue_add>. A pointer to the
-new event is returned on success and NULL is returned on error.
-
-B<ossl_event_free> frees an allocated event returned by B<ossl_event_new>.
-Does nothing if passed a pointer to a static event object which was initialised
-using B<ossl_event_set>.
-
-B<ossl_event_time_until> returns the time until I<event> would
-trigger. The event need not be part of an event queue.
-
-B<ossl_event_queue_postpone_until> reschedules the I<event>, which must
-be scheduled as part of timer event queue I<queue>, so that it will activate
-at time I<when>.
-
-B<ossl_event_get_type> returns the type of the I<event>.
-
-B<ossl_event_get_priority> returns the priority of the I<event>.
-
-B<ossl_event_get_when> returns the triggering time of the I<event>.
-
-B<ossl_event_get0_payload> returns the payload for the I<event>, the length
-of the payload is stored in I<length>.
-
-=head2 Event queue
-
-B<OSSL_EVENT_QUEUE> is an opaque structure that defines a timer based
-event queue. Event queue objects can only be dynamically allocated.
-
-B<ossl_event_queue_new> returns a newly allocated event queue object.
-
-B<ossl_event_queue_free> frees a event queue object returned by
-B<ossl_event_queue_new>.
-
-B<ossl_event_queue_schedule> adds the specified I<event> to the timer
-event queue I<queue>. The I<event> must not already be contained by any
-timer event queue including I<queue>.
-
-B<ossl_event_queue_delete> removes the specified I<event> from the
-timer event queue I<queue>. The event must have previously been added
-to I<queue> using the B<ossl_event_queue_schedule> call and must not yet
-have triggered.
-
-B<ossl_event_queue_time_until_next> returns the time until the next
-event in the timer event queue I<queue> is scheduled to trigger.
-
-B<ossl_event_queue_get1_next_event> gets the next event to process.
-The event is removed from the event queue and, if dynamically allocated,
-must be freed by the caller. A NULL event is returned if there is no event
-to process.
-
-=head1 RETURN VALUES
-
-B<ossl_event_queue_new> returns a new timer queue or NULL on failure.
-
-B<ossl_event_new> returns a new event or NULL on failure.
-
-B<ossl_event_get_type>, B<ossl_event_get_priority> and
-B<ossl_event_get_when> return the corresponding event field.
-
-B<ossl_event_get0_payload> returns a pointer to the event's payload.
-
-B<ossl_event_queue_add>, B<ossl_event_queue_remove>,
-B<ossl_event_queue_postpone_until> and
-B<ossl_event_queue_get1_next_event> return 1 on success and 0 on failure.
-
-B<ossl_event_time_until> and B<ossl_event_queue_time_until_next>
-return a time until the next event or B<OSSL_TIME_INFINITY> if there is no
-next event.
-
-=head1 SEE ALSO
-
-L<OSSL_TIME(3)>
-
-=head1 HISTORY
-
-This functionality was added to OpenSSL 3.2.
-
-=head1 COPYRIGHT
-
-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
-L<https://www.openssl.org/source/license.html>.
-
-=cut
diff --git a/include/internal/event_queue.h b/include/internal/event_queue.h
deleted file mode 100644
index 3b1ba50741..0000000000
--- a/include/internal/event_queue.h
+++ /dev/null
@@ -1,163 +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
- */
-
-#ifndef OSSL_INTERNAL_EVENT_QUEUE_H
-# define OSSL_INTERNAL_EVENT_QUEUE_H
-# pragma once
-
-# include "internal/priority_queue.h"
-# include "internal/time.h"
-
-/*
- * Opaque type holding an event.
- */
-typedef struct ossl_event_st OSSL_EVENT;
-
-DEFINE_PRIORITY_QUEUE_OF(OSSL_EVENT);
-
-/*
- * Public type representing an event queue, the underlying structure being
- * opaque.
- */
-typedef struct ossl_event_queue_st OSSL_EVENT_QUEUE;
-
-/*
- * Public type representing a event queue entry.
- * It is (internally) public so that it can be embedded into other structures,
- * it should otherwise be treated as opaque.
- */
-struct ossl_event_st {
- uint32_t type; /* What type of event this is */
- uint32_t priority; /* What priority this event has */
- OSSL_TIME when; /* When the event is scheduled to happen */
- void *ctx; /* User argument passed to call backs */
- void *payload; /* Event specific data of unknown kind */
- size_t payload_size; /* Length (in bytes) of event specific data */
-
- /* These fields are for internal use only */
- PRIORITY_QUEUE_OF(OSSL_EVENT) *queue; /* Queue containing this event */
- size_t ref; /* ID for this event */
- unsigned int flag_dynamic : 1; /* Malloced or not? */
-};
-
-/*
- * Utility function to populate an event structure and add it to the queue
- */
-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);
-
-/*
- * Utility functions to extract event fields
- */
-static ossl_unused ossl_inline
-uint32_t ossl_event_get_type(const OSSL_EVENT *event)
-{
- return event->type;
-}
-
-static ossl_unused ossl_inline
-uint32_t ossl_event_get_priority(const OSSL_EVENT *event)
-{
- return event->priority;
-}
-
-static ossl_unused ossl_inline
-OSSL_TIME ossl_event_get_when(const OSSL_EVENT *event)
-{
- return event->when;
-}
-
-static ossl_unused ossl_inline
-void *ossl_event_get0_ctx(const OSSL_EVENT *event)
-{
- return event->ctx;
-}
-
-static ossl_unused ossl_inline
-void *ossl_event_get0_payload(const OSSL_EVENT *event, size_t *length)
-{
- if (length != NULL)
- *length = event->payload_size;
- return event->payload;
-}
-
-/*
- * Create and free a queue.
- */
-OSSL_EVENT_QUEUE *ossl_event_queue_new(void);
-void ossl_event_queue_free(OSSL_EVENT_QUEUE *queue);
-
-/*
- * Schedule a new event into an event queue.
- *
- * The event parameters are taken from the function arguments.
- *
- * The function returns NULL on failure and the added event on success.
- */
-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)
-;
-
-/*
- * Schedule an event into an event queue.
- *
- * The event parameters are taken from the function arguments.
- *
- * The function returns 0 on failure and 1 on success.
- */
-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);
-
-/*
- * Delete an event from the queue.
- * This will cause the early deletion function to be called if it is non-NULL.
- * A pointer to the event structure is returned.
- */
-int ossl_event_queue_remove(OSSL_EVENT_QUEUE *queue, OSSL_EVENT *event);
-
-/*
- * Free a dynamic event.
- * Is a NOP for a static event.
- */
-void ossl_event_free(OSSL_EVENT *event);
-
-/*
- * Return the time until the next event for the specified event, if the event's
- * time is past, zero is returned. Once activated, the event reference becomes
- * invalid and this function becomes undefined.
- */
-OSSL_TIME ossl_event_time_until(const OSSL_EVENT *event);
-
-/*
- * Return the time until the next event in the queue.
- * If the next event is in the past, zero is returned.
- */
-OSSL_TIME ossl_event_queue_time_until_next(const OSSL_EVENT_QUEUE *queue);
-
-/*
- * Postpone an event to trigger at the specified time.
- * If the event has triggered, this function's behaviour is undefined.
- */
-int ossl_event_queue_postpone_until(OSSL_EVENT_QUEUE *queue,
- OSSL_EVENT *event,
- OSSL_TIME when);
-
-/*
- * Return the next event to process.
- */
-int ossl_event_queue_get1_next_event(OSSL_EVENT_QUEUE *queue,
- OSSL_EVENT **event);
-
-#endif
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;
-}
diff --git a/test/build.info b/test/build.info
index be7a9e312a..7fd0ab3311 100644
--- a/test/build.info
+++ b/test/build.info
@@ -75,7 +75,7 @@ IF[{- !$disabled{tests} -}]
ENDIF
IF[{- !$disabled{quic} -}]
- PROGRAMS{noinst}=priority_queue_test event_queue_test quicfaultstest quicapitest \
+ PROGRAMS{noinst}=priority_queue_test quicfaultstest quicapitest \
quic_newcid_test quic_srt_gen_test
ENDIF
@@ -878,10 +878,6 @@ IF[{- !$disabled{tests} -}]
INCLUDE[priority_queue_test]=../include ../apps/include
DEPEND[priority_queue_test]=../libcrypto ../libssl.a libtestutil.a
- SOURCE[event_queue_test]=event_queue_test.c
- INCLUDE[event_queue_test]=../include ../apps/include
- DEPEND[event_queue_test]=../libcrypto ../libssl.a libtestutil.a
-
SOURCE[quicfaultstest]=quicfaultstest.c helpers/ssltestlib.c $QUICTESTHELPERS
INCLUDE[quicfaultstest]=../include ../apps/include ..
DEPEND[quicfaultstest]=../libcrypto.a ../libssl.a libtestutil.a
diff --git a/test/event_queue_test.c b/test/event_queue_test.c
deleted file mode 100644
index 686233c930..0000000000
--- a/test/event_queue_test.c
+++ /dev/null
@@ -1,112 +0,0 @@
-/*
- * Copyright 2022 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 "internal/event_queue.h"
-#include "internal/nelem.h"
-#include "testutil.h"
-
-static OSSL_TIME cur_time = { 100 };
-
-OSSL_TIME ossl_time_now(void)
-{
- return cur_time;
-}
-
-#define PAYLOAD(s) s, strlen(s) + 1
-
-static int event_test(void)
-{
- int res = 0;
- size_t len = 0;
- OSSL_EVENT *e1, *e2, e3, *e4 = NULL, *ep = NULL;
- OSSL_EVENT_QUEUE *q = NULL;
- void *p;
- static char payload[] = "payload";
-
- /* Create an event queue and add some events */
- if (!TEST_ptr(q = ossl_event_queue_new())
- || !TEST_ptr(e1 = ossl_event_queue_add_new(q, 1, 10,
- ossl_ticks2time(1100),
- "ctx 1",
- PAYLOAD(payload)))
- || !TEST_ptr(e2 = ossl_event_queue_add_new(q, 2, 5,
- ossl_ticks2time(1100),
- "ctx 2",
- PAYLOAD("data")))
- || !TEST_true(ossl_event_queue_add(q, &e3, 3, 20,
- ossl_ticks2time(1200), "ctx 3",
- PAYLOAD("more data")))
- || !TEST_ptr(e4 = ossl_event_queue_add_new(q, 2, 5,
- ossl_ticks2time(1150),
- "ctx 2",
- PAYLOAD("data")))
-
- /* Verify some event details */
- || !TEST_uint_eq(ossl_event_get_type(e1), 1)
- || !TEST_uint_eq(ossl_event_get_priority(e1), 10)
- || !TEST_uint64_t_eq(ossl_time2ticks(ossl_event_get_when(e1))
- , 1100)
- || !TEST_str_eq(ossl_event_get0_ctx(e1), "ctx 1")
- || !TEST_ptr(p = ossl_event_get0_payload(e1, &len))
- || !TEST_str_eq((char *)p, payload)
- || !TEST_uint64_t_eq(ossl_time2ticks(ossl_event_time_until(&e3)),
- 1100)
- || !TEST_uint64_t_eq(ossl_time2ticks(ossl_event_queue_time_until_next(q)),
- 1000)
-
- /* Modify an event's time */
- || !TEST_true(ossl_event_queue_postpone_until(q, e1,
- ossl_ticks2time(1200)))
- || !TEST_uint64_t_eq(ossl_time2ticks(ossl_event_get_when(e1)), 1200)
- || !TEST_true(ossl_event_queue_remove(q, e4)))
- goto err;
- ossl_event_free(e4);
-
- /* Execute the queue */
- cur_time = ossl_ticks2time(1000);
- if (!TEST_true(ossl_event_queue_get1_next_event(q, &ep))
- || !TEST_ptr_null(ep))
- goto err;
- cur_time = ossl_ticks2time(1100);
- if (!TEST_true(ossl_event_queue_get1_next_event(q, &ep))
- || !TEST_ptr_eq(ep, e2))
- goto err;
- ossl_event_free(ep);
- ep = e2 = NULL;
- if (!TEST_true(ossl_event_queue_get1_next_event(q, &ep))
- || !TEST_ptr_null(ep))
- goto err;
-
- cur_time = ossl_ticks2time(1250);
- if (!TEST_true(ossl_event_queue_get1_next_event(q, &ep))
- || !TEST_ptr_eq(ep, &e3))
- goto err;
- ossl_event_free(ep);
- ep = NULL;
- if (!TEST_true(ossl_event_queue_get1_next_event(q, &ep))
- || !TEST_ptr_eq(ep, e1))
- goto err;
- ossl_event_free(ep);
- ep = e1 = NULL;
- if (!TEST_true(ossl_event_queue_get1_next_event(q, &ep))
- || !TEST_ptr_null(ep))
- goto err;
-
- res = 1;
- err:
- ossl_event_free(ep);
- ossl_event_queue_free(q);
- return res;
-}
-
-int setup_tests(void)
-{
- ADD_TEST(event_test);
- return 1;
-}