JBoss Native SVN: r1090 - trunk/sight/native/os/linux.
by jbossnative-commits@lists.jboss.org
Author: mladen.turk(a)jboss.com
Date: 2007-10-06 04:41:59 -0400 (Sat, 06 Oct 2007)
New Revision: 1090
Modified:
trunk/sight/native/os/linux/process.c
Log:
Optimize the term0 code -detect pid sanity
Modified: trunk/sight/native/os/linux/process.c
===================================================================
--- trunk/sight/native/os/linux/process.c 2007-10-06 08:39:16 UTC (rev 1089)
+++ trunk/sight/native/os/linux/process.c 2007-10-06 08:41:59 UTC (rev 1090)
@@ -563,6 +563,10 @@
pid_t pg;
#endif
+ /* Ensure pid sanity */
+ if (pid < 1)
+ return APR_EINVAL;
+
#ifndef HAVE_GETPGID
proc.pid = pid;
rv = apr_proc_wait(&proc, &status, &why, APR_NOWAIT);
17 years, 2 months
JBoss Native SVN: r1089 - trunk/sight/native/os/linux.
by jbossnative-commits@lists.jboss.org
Author: mladen.turk(a)jboss.com
Date: 2007-10-06 04:39:16 -0400 (Sat, 06 Oct 2007)
New Revision: 1089
Modified:
trunk/sight/native/os/linux/process.c
Log:
Optimize the term0 code - separate declaration from implementation
Modified: trunk/sight/native/os/linux/process.c
===================================================================
--- trunk/sight/native/os/linux/process.c 2007-10-06 08:36:58 UTC (rev 1088)
+++ trunk/sight/native/os/linux/process.c 2007-10-06 08:39:16 UTC (rev 1089)
@@ -559,12 +559,11 @@
apr_status_t rv;
apr_exit_why_e why;
int status;
+#else
+ pid_t pg;
+#endif
- UNREFERENCED_STDARGS;
- /* Ensure pid sanity */
- if (pid < 1)
- return APR_EINVAL;
-
+#ifndef HAVE_GETPGID
proc.pid = pid;
rv = apr_proc_wait(&proc, &status, &why, APR_NOWAIT);
if (rv == APR_CHILD_DONE) {
@@ -575,13 +574,6 @@
return rv;
}
#else
- pid_t pg;
-
- UNREFERENCED_STDARGS;
- /* Ensure pid sanity */
- if (pid < 1)
- return APR_EINVAL;
-
pg = getpgid(pid);
if (pg == -1) {
/* Process already dead... */
17 years, 2 months
JBoss Native SVN: r1088 - trunk/sight/native/os/linux.
by jbossnative-commits@lists.jboss.org
Author: mladen.turk(a)jboss.com
Date: 2007-10-06 04:36:58 -0400 (Sat, 06 Oct 2007)
New Revision: 1088
Modified:
trunk/sight/native/os/linux/process.c
Log:
Optimize the term0 code - take2
Modified: trunk/sight/native/os/linux/process.c
===================================================================
--- trunk/sight/native/os/linux/process.c 2007-10-06 08:36:02 UTC (rev 1087)
+++ trunk/sight/native/os/linux/process.c 2007-10-06 08:36:58 UTC (rev 1088)
@@ -554,18 +554,16 @@
SIGHT_EXPORT_DECLARE(jint, Process, term0)(SIGHT_STDARGS, jint pid,
jint signum)
{
- UNREFERENCED_STDARGS;
-
- /* Ensure pid sanity */
- if (pid < 1)
- return APR_EINVAL;
-
#ifndef HAVE_GETPGID
apr_proc_t proc;
apr_status_t rv;
apr_exit_why_e why;
int status;
+ UNREFERENCED_STDARGS;
+ /* Ensure pid sanity */
+ if (pid < 1)
+ return APR_EINVAL;
proc.pid = pid;
rv = apr_proc_wait(&proc, &status, &why, APR_NOWAIT);
@@ -579,6 +577,11 @@
#else
pid_t pg;
+ UNREFERENCED_STDARGS;
+ /* Ensure pid sanity */
+ if (pid < 1)
+ return APR_EINVAL;
+
pg = getpgid(pid);
if (pg == -1) {
/* Process already dead... */
17 years, 2 months
JBoss Native SVN: r1087 - trunk/sight/native/os/linux.
by jbossnative-commits@lists.jboss.org
Author: mladen.turk(a)jboss.com
Date: 2007-10-06 04:36:02 -0400 (Sat, 06 Oct 2007)
New Revision: 1087
Modified:
trunk/sight/native/os/linux/process.c
Log:
Optimize the term0 code
Modified: trunk/sight/native/os/linux/process.c
===================================================================
--- trunk/sight/native/os/linux/process.c 2007-10-06 08:32:13 UTC (rev 1086)
+++ trunk/sight/native/os/linux/process.c 2007-10-06 08:36:02 UTC (rev 1087)
@@ -554,16 +554,18 @@
SIGHT_EXPORT_DECLARE(jint, Process, term0)(SIGHT_STDARGS, jint pid,
jint signum)
{
+ UNREFERENCED_STDARGS;
+
+ /* Ensure pid sanity */
+ if (pid < 1)
+ return APR_EINVAL;
+
#ifndef HAVE_GETPGID
apr_proc_t proc;
apr_status_t rv;
apr_exit_why_e why;
int status;
- /* Ensure pid sanity */
- if (pid < 1) {
- return APR_EINVAL;
- }
proc.pid = pid;
rv = apr_proc_wait(&proc, &status, &why, APR_NOWAIT);
@@ -577,11 +579,6 @@
#else
pid_t pg;
- /* Ensure pid sanity. */
- if (pid < 1) {
- return APR_EINVAL;
- }
-
pg = getpgid(pid);
if (pg == -1) {
/* Process already dead... */
17 years, 2 months
JBoss Native SVN: r1086 - in trunk/sight/native: os/linux and 1 other directories.
by jbossnative-commits@lists.jboss.org
Author: mladen.turk(a)jboss.com
Date: 2007-10-06 04:32:13 -0400 (Sat, 06 Oct 2007)
New Revision: 1086
Modified:
trunk/sight/native/configure.in
trunk/sight/native/os/linux/process.c
trunk/sight/native/share/no.c
Log:
Make term more robust. This is actually from Apache Httpd
Modified: trunk/sight/native/configure.in
===================================================================
--- trunk/sight/native/configure.in 2007-10-04 06:24:12 UTC (rev 1085)
+++ trunk/sight/native/configure.in 2007-10-06 08:32:13 UTC (rev 1086)
@@ -264,7 +264,7 @@
AC_CHECK_HEADERS([netinet/tcp.h])
dnl ----------------------------- Checking for missing POSIX thread functions
-AC_CHECK_FUNCS([getpwnam_r getpwuid_r getgrnam_r getgrgid_r])
+AC_CHECK_FUNCS([getpwnam_r getpwuid_r getgrnam_r getgrgid_r getpgid])
if test -d $srcdir/test; then
Modified: trunk/sight/native/os/linux/process.c
===================================================================
--- trunk/sight/native/os/linux/process.c 2007-10-04 06:24:12 UTC (rev 1085)
+++ trunk/sight/native/os/linux/process.c 2007-10-06 08:32:13 UTC (rev 1086)
@@ -554,13 +554,46 @@
SIGHT_EXPORT_DECLARE(jint, Process, term0)(SIGHT_STDARGS, jint pid,
jint signum)
{
- jint rv = APR_SUCCESS;
+#ifndef HAVE_GETPGID
+ apr_proc_t proc;
+ apr_status_t rv;
+ apr_exit_why_e why;
+ int status;
- if (kill(pid, signum) == -1) {
+ /* Ensure pid sanity */
+ if (pid < 1) {
+ return APR_EINVAL;
+ }
+
+ proc.pid = pid;
+ rv = apr_proc_wait(&proc, &status, &why, APR_NOWAIT);
+ if (rv == APR_CHILD_DONE) {
+ /* Process already dead... */
+ return APR_EINVAL;
+ }
+ else if (rv != APR_CHILD_NOTDONE) {
+ return rv;
+ }
+#else
+ pid_t pg;
+
+ /* Ensure pid sanity. */
+ if (pid < 1) {
+ return APR_EINVAL;
+ }
+
+ pg = getpgid(pid);
+ if (pg == -1) {
+ /* Process already dead... */
return apr_get_os_error();
}
+#endif
+
+ if (kill(pid, signum)) {
+ return apr_get_os_error();
+ }
else
- return rv;
+ return APR_SUCCESS;
}
SIGHT_EXPORT_DECLARE(jint, Process, signal0)(SIGHT_STDARGS, jint pid,
Modified: trunk/sight/native/share/no.c
===================================================================
--- trunk/sight/native/share/no.c 2007-10-04 06:24:12 UTC (rev 1085)
+++ trunk/sight/native/share/no.c 2007-10-06 08:32:13 UTC (rev 1086)
@@ -194,12 +194,16 @@
} SIGHT_LOCAL_END(no);
}
+#define OPTIMISTIC_LOCK_CNT 10000
+#define OPTIMISTIC_LOCK_MAX OPTIMISTIC_LOCK_CNT + 60000
+
SIGHT_EXPORT_DECLARE(void, NativeObject, free0)(SIGHT_STDARGS,
jlong instance)
{
sight_object_t *no = J2P(instance, sight_object_t *);
jobject object = NULL;
#if SIGHT_APR_REFCOUNT
+ apr_uint32_t ioc = 0;
apr_uint32_t refcount;
#endif
@@ -222,6 +226,21 @@
while (refcount) {
apr_thread_yield();
refcount = apr_atomic_read32(&no->refcount);
+ if (ioc++ > OPTIMISTIC_LOCK_CNT) {
+ /* Sleep one millisecond */
+ apr_sleep(1000L);
+ }
+ if (ioc > OPTIMISTIC_LOCK_MAX) {
+ /* TODO: We have a zombie or a lengthy JNI op.
+ * Find a way to bail out without crushing JVM
+ */
+#ifdef SIGHT_DO_STATS
+ fprintf(stderr, "Native.object() call is locked ...\n");
+ fprintf(stderr, "Bailing out !\n");
+ fflush(stderr);
+ exit(-1);
+#endif
+ }
}
#endif
if (no->pool)
@@ -250,6 +269,7 @@
{
sight_object_t *no = J2P(instance, sight_object_t *);
#if SIGHT_APR_REFCOUNT
+ apr_uint32_t ioc = 0;
apr_uint32_t refcount;
#endif
UNREFERENCED_O;
@@ -266,6 +286,22 @@
while (refcount) {
apr_thread_yield();
refcount = apr_atomic_read32(&no->refcount);
+ if (ioc++ > OPTIMISTIC_LOCK_CNT) {
+ /* Sleep one millisecond */
+ apr_sleep(1000L);
+ }
+ if (ioc > OPTIMISTIC_LOCK_MAX) {
+ /* TODO: We have a zombie or a lengthy JNI op.
+ * Find a way to bail out without crushing JVM
+ */
+#ifdef SIGHT_DO_STATS
+ fprintf(stderr, "NativeObject.clear() call is locked ...\n");
+ fprintf(stderr, "Bailing out !\n");
+ fflush(stderr);
+#endif
+ throwAprException(_E, APR_TIMEUP);
+ return;
+ }
}
#endif
if (no->pool)
@@ -280,6 +316,7 @@
no->opaque = NULL;
no->native = NULL;
}
+ apr_atomic_set32(&no->interrupted, 0);
} SIGHT_GLOBAL_END();
}
17 years, 2 months
JBoss Native SVN: r1085 - trunk/sight/native/share.
by jbossnative-commits@lists.jboss.org
Author: mladen.turk(a)jboss.com
Date: 2007-10-04 02:24:12 -0400 (Thu, 04 Oct 2007)
New Revision: 1085
Modified:
trunk/sight/native/share/no.c
Log:
Make sure interrupt is always set for clear and free calls
Modified: trunk/sight/native/share/no.c
===================================================================
--- trunk/sight/native/share/no.c 2007-10-04 06:21:54 UTC (rev 1084)
+++ trunk/sight/native/share/no.c 2007-10-04 06:24:12 UTC (rev 1085)
@@ -211,6 +211,7 @@
if (!no)
return;
SIGHT_GLOBAL_TRY {
+ apr_atomic_inc32(&no->interrupted);
if (no->object) {
object = (*_E)->NewLocalRef(_E, no->object);
(*_E)->DeleteWeakGlobalRef(_E, no->object);
@@ -259,10 +260,10 @@
if (!no)
return;
SIGHT_GLOBAL_TRY {
+ apr_atomic_inc32(&no->interrupted);
#if SIGHT_APR_REFCOUNT
refcount = apr_atomic_read32(&no->refcount);
while (refcount) {
- apr_atomic_inc32(&no->interrupted);
apr_thread_yield();
refcount = apr_atomic_read32(&no->refcount);
}
17 years, 2 months
JBoss Native SVN: r1084 - in trunk/sight: native/include and 1 other directories.
by jbossnative-commits@lists.jboss.org
Author: mladen.turk(a)jboss.com
Date: 2007-10-04 02:21:54 -0400 (Thu, 04 Oct 2007)
New Revision: 1084
Modified:
trunk/sight/java/org/jboss/sight/NativeObject.java
trunk/sight/native/include/sight_local.h
trunk/sight/native/include/sight_types.h
trunk/sight/native/share/no.c
Log:
Add NativeObject interrupt method for breaking the long JNI calls
Modified: trunk/sight/java/org/jboss/sight/NativeObject.java
===================================================================
--- trunk/sight/java/org/jboss/sight/NativeObject.java 2007-10-04 05:43:07 UTC (rev 1083)
+++ trunk/sight/java/org/jboss/sight/NativeObject.java 2007-10-04 06:21:54 UTC (rev 1084)
@@ -47,6 +47,7 @@
private static native void clear0(long instance);
private static native void cbset0(long instance, Object cb)
throws OutOfMemoryError;
+ private static native void intr0(long instance);
/**
* Create new NativeObject without APR pool
@@ -74,6 +75,14 @@
}
/**
+ * Interrupt the pending native operation.
+ */
+ public void interrupt()
+ {
+ intr0(INSTANCE);
+ }
+
+ /**
* Destroy the object.
*/
public void destroy()
Modified: trunk/sight/native/include/sight_local.h
===================================================================
--- trunk/sight/native/include/sight_local.h 2007-10-04 05:43:07 UTC (rev 1083)
+++ trunk/sight/native/include/sight_local.h 2007-10-04 06:21:54 UTC (rev 1084)
@@ -387,7 +387,6 @@
#define SIGHT_LOCAL_END(N) apr_atomic_dec32(&(N)->refcount); } apr_atomic_dec32(sight_global_atomic)
#define SIGHT_LOCAL_BRK(N) apr_atomic_dec32(&(N)->refcount); apr_atomic_dec32(sight_global_atomic)
-#define SIGHT_LOCAL_IRQ(N) apr_atomic_read32(&(N)->interrupted)
#else
#define SIGHT_GLOBAL_TRY
@@ -396,10 +395,11 @@
#define SIGHT_LOCAL_TRY(N) if ((N))
#define SIGHT_LOCAL_END(N)
#define SIGHT_LOCAL_BRK(N)
-#define SIGHT_LOCAL_IRQ(N)
#endif /* SIGHT_APR_REFCOUNT */
+#define SIGHT_LOCAL_IRQ(N) apr_atomic_read32(&(N)->interrupted)
+
/* Statistics counters */
extern volatile apr_uint64_t sight_cnt_native_alloc;
extern volatile apr_uint64_t sight_cnt_native_create;
Modified: trunk/sight/native/include/sight_types.h
===================================================================
--- trunk/sight/native/include/sight_types.h 2007-10-04 05:43:07 UTC (rev 1083)
+++ trunk/sight/native/include/sight_types.h 2007-10-04 06:21:54 UTC (rev 1084)
@@ -115,8 +115,8 @@
struct sight_object_t {
#if SIGHT_APR_REFCOUNT
volatile apr_uint32_t refcount;
+#endif
volatile apr_uint32_t interrupted;
-#endif
apr_pool_t *pool;
void *native;
void *opaque;
Modified: trunk/sight/native/share/no.c
===================================================================
--- trunk/sight/native/share/no.c 2007-10-04 05:43:07 UTC (rev 1083)
+++ trunk/sight/native/share/no.c 2007-10-04 06:21:54 UTC (rev 1084)
@@ -281,3 +281,14 @@
}
} SIGHT_GLOBAL_END();
}
+
+SIGHT_EXPORT_DECLARE(void, NativeObject, intr0)(SIGHT_STDARGS,
+ jlong instance)
+{
+ sight_object_t *no = J2P(instance, sight_object_t *);
+
+ UNREFERENCED_STDARGS;
+ if (no) {
+ apr_atomic_inc32(&no->interrupted);
+ }
+}
17 years, 2 months
JBoss Native SVN: r1083 - in trunk/sight: native/share and 1 other directory.
by jbossnative-commits@lists.jboss.org
Author: mladen.turk(a)jboss.com
Date: 2007-10-04 01:43:07 -0400 (Thu, 04 Oct 2007)
New Revision: 1083
Modified:
trunk/sight/java/org/jboss/sight/Library.java
trunk/sight/native/share/library.c
Log:
Make clear and terminate methods synchronized
Modified: trunk/sight/java/org/jboss/sight/Library.java
===================================================================
--- trunk/sight/java/org/jboss/sight/Library.java 2007-10-03 16:58:16 UTC (rev 1082)
+++ trunk/sight/java/org/jboss/sight/Library.java 2007-10-04 05:43:07 UTC (rev 1083)
@@ -76,7 +76,7 @@
/* create global SIGHT APR pool
* This has to be the first call to SIGHT library.
*/
- private static native boolean initialize();
+ private static native boolean initialize0();
/* destroy global SIGHT APR pool
* This has to be the last call to SIGHT library.
@@ -134,7 +134,7 @@
throw new UnsatisfiedLinkError("Unsupported APR Version (" +
getAprVersionString() + ")");
}
- if (initialize()) {
+ if (initialize0()) {
/* Initialize Runtime objects */
File.initializeStdFiles();
@@ -155,7 +155,9 @@
{
try {
if (_instance != null) {
- terminate0();
+ synchronized(_instance) {
+ terminate0();
+ }
}
else {
throw new UnsatisfiedLinkError("Library was not initialized");
@@ -186,9 +188,11 @@
throws Exception
{
if (_instance != null) {
- clear0();
- /* Reinitialize Runtime objects */
- File.initializeStdFiles();
+ synchronized(_instance) {
+ clear0();
+ /* Reinitialize Runtime objects */
+ File.initializeStdFiles();
+ }
}
else {
throw new UnsatisfiedLinkError("Library was not initialized");
Modified: trunk/sight/native/share/library.c
===================================================================
--- trunk/sight/native/share/library.c 2007-10-03 16:58:16 UTC (rev 1082)
+++ trunk/sight/native/share/library.c 2007-10-04 05:43:07 UTC (rev 1083)
@@ -153,7 +153,7 @@
}
}
-SIGHT_EXPORT_DECLARE(jboolean, Library, initialize)(SIGHT_STDARGS)
+SIGHT_EXPORT_DECLARE(jboolean, Library, initialize0)(SIGHT_STDARGS)
{
UNREFERENCED_STDARGS;
@@ -235,7 +235,7 @@
{
UNREFERENCED_STDARGS;
- /* TODO Add reference count */
+
if (sight_global_pool) {
#if SIGHT_APR_REFCOUNT
apr_uint32_t ioc = 0;
@@ -246,6 +246,8 @@
fprintf(stderr, "Global Atomic counter : %d\n", sight_global_a);
#endif
#if SIGHT_APR_REFCOUNT
+ /* Wait until all JNI calls are done
+ */
while (in_object_count) {
apr_thread_yield();
in_object_count = apr_atomic_read32(sight_global_atomic);
@@ -366,9 +368,9 @@
throwAprException(_E, APR_TIMEUP);
return;
}
-
+
#endif
-
+
apr_pool_clear(sight_global_pool);
apr_atomic_set32(sight_global_atomic, 1);
}
17 years, 2 months
JBoss Native SVN: r1082 - in trunk/sight/native: share and 1 other directory.
by jbossnative-commits@lists.jboss.org
Author: mladen.turk(a)jboss.com
Date: 2007-10-03 12:58:16 -0400 (Wed, 03 Oct 2007)
New Revision: 1082
Modified:
trunk/sight/native/include/sight_local.h
trunk/sight/native/include/sight_types.h
trunk/sight/native/share/library.c
trunk/sight/native/share/no.c
Log:
Add atomics option as compile time defined
Modified: trunk/sight/native/include/sight_local.h
===================================================================
--- trunk/sight/native/include/sight_local.h 2007-10-03 16:47:41 UTC (rev 1081)
+++ trunk/sight/native/include/sight_local.h 2007-10-03 16:58:16 UTC (rev 1082)
@@ -377,9 +377,6 @@
#endif
#endif
-/* For now use APR reference counters */
-#define SIGHT_APR_REFCOUNT 1
-
#if SIGHT_APR_REFCOUNT
#define SIGHT_GLOBAL_TRY if (apr_atomic_inc32(sight_global_atomic))
#define SIGHT_GLOBAL_END() apr_atomic_dec32(sight_global_atomic)
Modified: trunk/sight/native/include/sight_types.h
===================================================================
--- trunk/sight/native/include/sight_types.h 2007-10-03 16:47:41 UTC (rev 1081)
+++ trunk/sight/native/include/sight_types.h 2007-10-03 16:58:16 UTC (rev 1082)
@@ -59,6 +59,9 @@
#define SIGHT_MAX_PROCESSES 65536
+/* For now use APR reference counters */
+#define SIGHT_APR_REFCOUNT 1
+
typedef struct JAVA_C_ID {
jclass i;
jclass a;
@@ -110,8 +113,10 @@
/* org.jboss.sight.NativeObject instance */
struct sight_object_t {
+#if SIGHT_APR_REFCOUNT
volatile apr_uint32_t refcount;
volatile apr_uint32_t interrupted;
+#endif
apr_pool_t *pool;
void *native;
void *opaque;
Modified: trunk/sight/native/share/library.c
===================================================================
--- trunk/sight/native/share/library.c 2007-10-03 16:47:41 UTC (rev 1081)
+++ trunk/sight/native/share/library.c 2007-10-03 16:58:16 UTC (rev 1082)
@@ -233,16 +233,19 @@
SIGHT_EXPORT_DECLARE(void, Library, terminate0)(SIGHT_STDARGS)
{
- apr_uint32_t ioc = 0;
UNREFERENCED_STDARGS;
/* TODO Add reference count */
if (sight_global_pool) {
+#if SIGHT_APR_REFCOUNT
+ apr_uint32_t ioc = 0;
apr_uint32_t in_object_count = apr_atomic_dec32(sight_global_atomic);
+#endif
#ifdef SIGHT_DO_STATS
fprintf(stderr, "\nLibrary terminate ............\n");
fprintf(stderr, "Global Atomic counter : %d\n", sight_global_a);
#endif
+#if SIGHT_APR_REFCOUNT
while (in_object_count) {
apr_thread_yield();
in_object_count = apr_atomic_read32(sight_global_atomic);
@@ -262,6 +265,7 @@
#endif
}
}
+#endif
apr_pool_destroy(sight_temp_pool);
apr_pool_destroy(sight_global_pool);
sight_temp_pool = NULL;
@@ -328,19 +332,43 @@
SIGHT_EXPORT_DECLARE(void, Library, clear0)(SIGHT_STDARGS)
{
- UNREFERENCED_STDARGS;
+ UNREFERENCED_O;
+
if (sight_global_pool) {
+#if SIGHT_APR_REFCOUNT
+ apr_uint32_t ioc = 0;
apr_uint32_t in_object_count = apr_atomic_dec32(sight_global_atomic);
+#endif
/* Wait untill all object native calls are finished */
#ifdef SIGHT_DO_STATS
fprintf(stderr, "\nLibrary clear ................\n");
fprintf(stderr, "Global Atomic counter : %d\n", sight_global_a);
#endif
+#if SIGHT_APR_REFCOUNT
while (in_object_count) {
apr_thread_yield();
in_object_count = apr_atomic_read32(sight_global_atomic);
}
+ if (ioc++ > OPTIMISTIC_LOCK_CNT) {
+ /* Sleep one millisecond */
+ apr_sleep(1000L);
+ }
+ if (ioc > OPTIMISTIC_LOCK_MAX) {
+ /* TODO: We have a zombie or a lengthy JNI op.
+ * Find a way to bail out without crushing JVM
+ */
+#ifdef SIGHT_DO_STATS
+ fprintf(stderr, "Library.clear0() call is locked ...\n");
+ fprintf(stderr, "Bailing out !\n");
+ fflush(stderr);
+#endif
+ throwAprException(_E, APR_TIMEUP);
+ return;
+ }
+
+#endif
+
apr_pool_clear(sight_global_pool);
apr_atomic_set32(sight_global_atomic, 1);
}
Modified: trunk/sight/native/share/no.c
===================================================================
--- trunk/sight/native/share/no.c 2007-10-03 16:47:41 UTC (rev 1081)
+++ trunk/sight/native/share/no.c 2007-10-03 16:58:16 UTC (rev 1082)
@@ -199,7 +199,9 @@
{
sight_object_t *no = J2P(instance, sight_object_t *);
jobject object = NULL;
+#if SIGHT_APR_REFCOUNT
apr_uint32_t refcount;
+#endif
UNREFERENCED_O;
@@ -214,11 +216,13 @@
(*_E)->DeleteWeakGlobalRef(_E, no->object);
no->object = object;
}
+#if SIGHT_APR_REFCOUNT
refcount = apr_atomic_read32(&no->refcount);
while (refcount) {
apr_thread_yield();
refcount = apr_atomic_read32(&no->refcount);
}
+#endif
if (no->pool)
apr_pool_cleanup_kill(no->pool, no, native_object_cleanup);
if (no->object) {
@@ -244,8 +248,9 @@
jlong instance)
{
sight_object_t *no = J2P(instance, sight_object_t *);
+#if SIGHT_APR_REFCOUNT
apr_uint32_t refcount;
-
+#endif
UNREFERENCED_O;
#ifdef SIGHT_DO_STATS
@@ -254,13 +259,14 @@
if (!no)
return;
SIGHT_GLOBAL_TRY {
+#if SIGHT_APR_REFCOUNT
refcount = apr_atomic_read32(&no->refcount);
while (refcount) {
apr_atomic_inc32(&no->interrupted);
apr_thread_yield();
refcount = apr_atomic_read32(&no->refcount);
}
-
+#endif
if (no->pool)
apr_pool_cleanup_kill(no->pool, no, native_object_cleanup);
if (no->clean)
17 years, 2 months
JBoss Native SVN: r1081 - trunk/sight/native/include.
by jbossnative-commits@lists.jboss.org
Author: mladen.turk(a)jboss.com
Date: 2007-10-03 12:47:41 -0400 (Wed, 03 Oct 2007)
New Revision: 1081
Modified:
trunk/sight/native/include/sight_local.h
Log:
Add atomics option as compile time defined
Modified: trunk/sight/native/include/sight_local.h
===================================================================
--- trunk/sight/native/include/sight_local.h 2007-10-03 16:07:16 UTC (rev 1080)
+++ trunk/sight/native/include/sight_local.h 2007-10-03 16:47:41 UTC (rev 1081)
@@ -377,19 +377,32 @@
#endif
#endif
+/* For now use APR reference counters */
+#define SIGHT_APR_REFCOUNT 1
+
+#if SIGHT_APR_REFCOUNT
#define SIGHT_GLOBAL_TRY if (apr_atomic_inc32(sight_global_atomic))
#define SIGHT_GLOBAL_END() apr_atomic_dec32(sight_global_atomic)
#define SIGHT_GLOBAL_BRK() apr_atomic_dec32(sight_global_atomic)
-
#define SIGHT_LOCAL_TRY(N) { apr_uint32_t _SGATOM = apr_atomic_inc32(sight_global_atomic); \
if ((N)) apr_atomic_inc32(&(N)->refcount); \
if ((N) && _SGATOM)
#define SIGHT_LOCAL_END(N) apr_atomic_dec32(&(N)->refcount); } apr_atomic_dec32(sight_global_atomic)
#define SIGHT_LOCAL_BRK(N) apr_atomic_dec32(&(N)->refcount); apr_atomic_dec32(sight_global_atomic)
-
#define SIGHT_LOCAL_IRQ(N) apr_atomic_read32(&(N)->interrupted)
+#else
+#define SIGHT_GLOBAL_TRY
+#define SIGHT_GLOBAL_END()
+#define SIGHT_GLOBAL_BRK()
+#define SIGHT_LOCAL_TRY(N) if ((N))
+#define SIGHT_LOCAL_END(N)
+#define SIGHT_LOCAL_BRK(N)
+#define SIGHT_LOCAL_IRQ(N)
+
+#endif /* SIGHT_APR_REFCOUNT */
+
/* Statistics counters */
extern volatile apr_uint64_t sight_cnt_native_alloc;
extern volatile apr_uint64_t sight_cnt_native_create;
17 years, 2 months