Author: mladen.turk(a)jboss.com
Date: 2007-10-01 04:54:47 -0400 (Mon, 01 Oct 2007)
New Revision: 1068
Modified:
trunk/sight/native/share/no.c
trunk/sight/native/share/shm.c
Log:
Seal shared memory JNI calls
Modified: trunk/sight/native/share/no.c
===================================================================
--- trunk/sight/native/share/no.c 2007-10-01 08:44:34 UTC (rev 1067)
+++ trunk/sight/native/share/no.c 2007-10-01 08:54:47 UTC (rev 1068)
@@ -264,10 +264,11 @@
refcount = apr_atomic_read32(&no->refcount);
}
+ if (no->pool)
+ apr_pool_cleanup_kill(no->pool, no, native_object_cleanup);
+ if (no->clean)
+ (*no->clean)(POOL_CLEAR, no);
if (no->pool) {
- apr_pool_cleanup_kill(no->pool, no, native_object_cleanup);
- if (no->clean)
- (*no->clean)(POOL_CLEAR, no);
apr_pool_clear(no->pool);
apr_pool_cleanup_register(no->pool, (const void *)no,
native_object_cleanup,
Modified: trunk/sight/native/share/shm.c
===================================================================
--- trunk/sight/native/share/shm.c 2007-10-01 08:44:34 UTC (rev 1067)
+++ trunk/sight/native/share/shm.c 2007-10-01 08:54:47 UTC (rev 1068)
@@ -57,14 +57,15 @@
rv = APR_ENOPOOL;
goto cleanup;
}
+ SIGHT_LOCAL_TRY(no) {
+ rv = apr_shm_create(&shm, (apr_size_t)size, J2S(name), no->pool);
- rv = apr_shm_create(&shm, (apr_size_t)size, J2S(name), no->pool);
-
- if (rv == APR_SUCCESS) {
- no->clean = shm_cleanup;
- no->native = shm;
- no->opaque = NULL;
- }
+ if (rv == APR_SUCCESS) {
+ no->clean = shm_cleanup;
+ no->native = shm;
+ no->opaque = NULL;
+ }
+ } SIGHT_LOCAL_END(no);
cleanup:
SIGHT_FREE_CSTRING(name);
return rv;
@@ -87,13 +88,15 @@
goto cleanup;
}
- rv = apr_shm_attach(&shm, J2S(name), no->pool);
+ SIGHT_LOCAL_TRY(no) {
+ rv = apr_shm_attach(&shm, J2S(name), no->pool);
- if (rv == APR_SUCCESS) {
- no->clean = shm_cleanup;
- no->native = shm;
- no->opaque = shm;
- }
+ if (rv == APR_SUCCESS) {
+ no->clean = shm_cleanup;
+ no->native = shm;
+ no->opaque = shm;
+ }
+ } SIGHT_LOCAL_END(no);
cleanup:
SIGHT_FREE_CSTRING(name);
return rv;
@@ -118,15 +121,19 @@
UNREFERENCED_O;
if (no && no->native) {
- jbyte *base = (jbyte *)apr_shm_baseaddr_get(no->native);
- apr_size_t siz;
- if (asize < 0)
- siz = apr_shm_size_get(no->native);
- else
- siz = (apr_size_t)asize;
- if (siz > 0 && base) {
- return (*_E)->NewDirectByteBuffer(_E, base, siz);
- }
+ jobject rv = NULL;
+ SIGHT_LOCAL_TRY(no) {
+ jbyte *base = (jbyte *)apr_shm_baseaddr_get(no->native);
+ apr_size_t siz;
+ if (asize < 0)
+ siz = apr_shm_size_get(no->native);
+ else
+ siz = (apr_size_t)asize;
+ if (siz > 0 && base) {
+ rv = (*_E)->NewDirectByteBuffer(_E, base, siz);
+ }
+ } SIGHT_LOCAL_END(no);
+ return rv;
}
return NULL;
}
@@ -135,15 +142,16 @@
jstring name,
jlong pool)
{
- apr_status_t rv;
+ apr_status_t rv = APR_ENOPOOL;
apr_pool_t *p = J2P(pool, apr_pool_t *);
SIGHT_ALLOC_CSTRING(name);
+
UNREFERENCED_O;
if (p) {
- rv = apr_shm_remove(J2S(name), p);
+ SIGHT_GLOBAL_TRY {
+ rv = apr_shm_remove(J2S(name), p);
+ } SIGHT_GLOBAL_END();
}
- else
- rv = APR_ENOPOOL;
SIGHT_FREE_CSTRING(name);
return rv;
}
Show replies by date