You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@apr.apache.org by iv...@apache.org on 2025/06/13 20:44:54 UTC
svn commit: r1926399 - /apr/apr/trunk/test/testshm.c
Author: ivan
Date: Fri Jun 13 20:44:53 2025
New Revision: 1926399
URL: http://svn.apache.org/viewvc?rev=1926399&view=rev
Log:
* test/testshm.c: Close (deatch) shared memory object after delete, because
some platforms (e.g. Windows) doesn't delete object until last handle is closed.
Modified:
apr/apr/trunk/test/testshm.c
Modified: apr/apr/trunk/test/testshm.c
URL: http://svn.apache.org/viewvc/apr/apr/trunk/test/testshm.c?rev=1926399&r1=1926398&r2=1926399&view=diff
==============================================================================
--- apr/apr/trunk/test/testshm.c (original)
+++ apr/apr/trunk/test/testshm.c Fri Jun 13 20:44:53 2025
@@ -208,6 +208,7 @@ static void test_named(abts_case *tc, vo
static void test_named_remove(abts_case *tc, void *data)
{
apr_status_t rv;
+ apr_status_t rv2;
apr_shm_t *shm, *shm2;
apr_shm_remove(SHARED_FILENAME, p);
@@ -221,6 +222,11 @@ static void test_named_remove(abts_case
rv = apr_shm_remove(SHARED_FILENAME, p);
+ /* On some platforms (e.g. Windows), objects are alive until last handle
+ * is closed. So detach from shared memory. */
+ rv2 = apr_shm_detach(shm);
+ APR_ASSERT_SUCCESS(tc, "Error detach shared memory block", rv);
+
/* On platforms which acknowledge the removal of the shared resource,
* ensure another of the same name may be created after removal;
*/
@@ -237,9 +243,6 @@ static void test_named_remove(abts_case
APR_ASSERT_SUCCESS(tc, "Error destroying shared memory block", rv);
}
- rv = apr_shm_destroy(shm);
- APR_ASSERT_SUCCESS(tc, "Error destroying shared memory block", rv);
-
/* Now ensure no named resource remains which we may attach to */
rv = apr_shm_attach(&shm, SHARED_FILENAME, p);
ABTS_TRUE(tc, rv != 0);
@@ -248,6 +251,7 @@ static void test_named_remove(abts_case
static void test_named_delete(abts_case *tc, void *data)
{
apr_status_t rv;
+ apr_status_t rv2;
apr_shm_t *shm, *shm2;
apr_shm_remove(SHARED_FILENAME, p);
@@ -261,6 +265,11 @@ static void test_named_delete(abts_case
rv = apr_shm_delete(shm);
+ /* On some platforms (e.g. Windows), objects are alive until last handle
+ * is closed. So detach from shared memory. */
+ rv2 = apr_shm_detach(shm);
+ APR_ASSERT_SUCCESS(tc, "Error detach shared memory block", rv);
+
/* On platforms which acknowledge the removal of the shared resource,
* ensure another of the same name may be created after removal;
*/
@@ -277,9 +286,6 @@ static void test_named_delete(abts_case
APR_ASSERT_SUCCESS(tc, "Error destroying shared memory block", rv);
}
- rv = apr_shm_destroy(shm);
- APR_ASSERT_SUCCESS(tc, "Error destroying shared memory block", rv);
-
/* Now ensure no named resource remains which we may attach to */
rv = apr_shm_attach(&shm, SHARED_FILENAME, p);
ABTS_TRUE(tc, rv != 0);