summaryrefslogtreecommitdiffstats
path: root/test/property_test.c
diff options
context:
space:
mode:
authorPauli <paul.dale@oracle.com>2019-11-11 11:17:32 +1000
committerPauli <paul.dale@oracle.com>2019-11-18 18:51:26 +1000
commitbdbf2df2e685ae653f3c683ce2f734eb0c0888e0 (patch)
tree832a32165746bb33f8be34f196525031ac3a93bf /test/property_test.c
parentf75abcc0f073b1c3e2d81df3fcde8fe45dd1e61f (diff)
Properties: make query cache reference count aware.
The property query cache was not reference count aware and this could cause problems if the property store removes an algorithm while it is being returned from an asynchronous query. This change makes the cache reference count aware and avoids disappearing algorithms. A side effect of this change is that the reference counts are now owned by the cache and store. Reviewed-by: Richard Levitte <levitte@openssl.org> (Merged from https://github.com/openssl/openssl/pull/10408)
Diffstat (limited to 'test/property_test.c')
-rw-r--r--test/property_test.c21
1 files changed, 16 insertions, 5 deletions
diff --git a/test/property_test.c b/test/property_test.c
index 8b953e41e2..ca407b2ba4 100644
--- a/test/property_test.c
+++ b/test/property_test.c
@@ -28,6 +28,15 @@ static int add_property_names(const char *n, ...)
return res;
}
+static int up_ref(void *p)
+{
+ return 1;
+}
+
+static void down_ref(void *p)
+{
+}
+
static int test_property_string(void)
{
OSSL_METHOD_STORE *store;
@@ -242,7 +251,7 @@ static int test_register_deregister(void)
for (i = 0; i < OSSL_NELEM(impls); i++)
if (!TEST_true(ossl_method_store_add(store, NULL, impls[i].nid,
impls[i].prop, impls[i].impl,
- NULL, NULL))) {
+ &up_ref, &down_ref))) {
TEST_note("iteration %zd", i + 1);
goto err;
}
@@ -310,7 +319,7 @@ static int test_property(void)
for (i = 0; i < OSSL_NELEM(impls); i++)
if (!TEST_true(ossl_method_store_add(store, NULL, impls[i].nid,
impls[i].prop, impls[i].impl,
- NULL, NULL))) {
+ &up_ref, &down_ref))) {
TEST_note("iteration %zd", i + 1);
goto err;
}
@@ -350,10 +359,12 @@ static int test_query_cache_stochastic(void)
v[i] = 2 * i;
BIO_snprintf(buf, sizeof(buf), "n=%d\n", i);
if (!TEST_true(ossl_method_store_add(store, NULL, i, buf, "abc",
- NULL, NULL))
- || !TEST_true(ossl_method_store_cache_set(store, i, buf, v + i))
+ &up_ref, &down_ref))
+ || !TEST_true(ossl_method_store_cache_set(store, i, buf, v + i,
+ &up_ref, &down_ref))
|| !TEST_true(ossl_method_store_cache_set(store, i, "n=1234",
- "miss"))) {
+ "miss", &up_ref,
+ &down_ref))) {
TEST_note("iteration %d", i);
goto err;
}