You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by jf...@apache.org on 2005/05/09 17:14:57 UTC

svn commit: r169326 - /jakarta/commons/proper/daemon/trunk/src/native/unix/native/java.c /jakarta/commons/proper/daemon/trunk/src/native/unix/native/jsvc-unix.c

Author: jfclere
Date: Mon May  9 08:14:56 2005
New Revision: 169326

URL: http://svn.apache.org/viewcvs?rev=169326&view=rev
Log:
replace pause() by call of the java/lang/Thread.sleep().

Modified:
    jakarta/commons/proper/daemon/trunk/src/native/unix/native/java.c
    jakarta/commons/proper/daemon/trunk/src/native/unix/native/jsvc-unix.c

Modified: jakarta/commons/proper/daemon/trunk/src/native/unix/native/java.c
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/daemon/trunk/src/native/unix/native/java.c?rev=169326&r1=169325&r2=169326&view=diff
==============================================================================
--- jakarta/commons/proper/daemon/trunk/src/native/unix/native/java.c (original)
+++ jakarta/commons/proper/daemon/trunk/src/native/unix/native/java.c Mon May  9 08:14:56 2005
@@ -271,7 +271,7 @@
     jsvc_xlate_to_ascii(exitparams);
     method=(*env)->GetStaticMethodID(env,system,exitclass,exitparams);
     if (method==NULL) {
-        log_error("Cannot found \"System.exit(int)\" entry point");
+        log_error("Cannot find \"System.exit(int)\" entry point");
         return(false);
     }
 
@@ -335,7 +335,7 @@
     jsvc_xlate_to_ascii(loadparams);
     method=(*env)->GetStaticMethodID(env,cls,load,loadparams);
     if (method==NULL) {
-        log_error("Cannot found Daemon Loader \"load\" entry point");
+        log_error("Cannot find Daemon Loader \"load\" entry point");
         return(false);
     }
 
@@ -360,7 +360,7 @@
     jsvc_xlate_to_ascii(startparams); 
     method=(*env)->GetStaticMethodID(env,cls,start,startparams);
     if (method==NULL) {
-        log_error("Cannot found Daemon Loader \"start\" entry point");
+        log_error("Cannot find Daemon Loader \"start\" entry point");
         return(false);
     }
 
@@ -372,6 +372,34 @@
 
     log_debug("Daemon started successfully");
     return(true);
+}
+
+/*
+ * call the java sleep to prevent problems with threads
+ */
+void java_sleep(int wait) {
+    jclass clsThread;
+    jmethodID method;
+    char jsleep[]="sleep";
+    char jsleepparams[]="(J)V";
+    char jthread[]="java/lang/Thread"; 
+ 
+    jsvc_xlate_to_ascii(jsleep);
+    jsvc_xlate_to_ascii(jsleepparams);
+    jsvc_xlate_to_ascii(jthread);
+
+    clsThread = (*env)->FindClass(env,jthread);
+    if (clsThread==NULL) {
+        log_error("Cannot find java/lang/Thread class");
+        return;
+    }
+    method=(*env)->GetStaticMethodID(env,clsThread,jsleep,jsleepparams);
+    if (method==NULL) {
+        log_error("Cannot found the sleep entry point");
+        return;
+    }
+ 
+    (*env)->CallStaticVoidMethod(env,clsThread,method,(jlong)wait*1000);
 }
 
 /* Call the stop method in our daemon loader */

Modified: jakarta/commons/proper/daemon/trunk/src/native/unix/native/jsvc-unix.c
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/daemon/trunk/src/native/unix/native/jsvc-unix.c?rev=169326&r1=169325&r2=169326&view=diff
==============================================================================
--- jakarta/commons/proper/daemon/trunk/src/native/unix/native/jsvc-unix.c (original)
+++ jakarta/commons/proper/daemon/trunk/src/native/unix/native/jsvc-unix.c Mon May  9 08:14:56 2005
@@ -504,7 +504,8 @@
     create_tmp_file(args);
     while (!stopping) {
 #ifdef OSD_POSIX
-        pause();
+        java_sleep(60);
+        /* pause(); */
 #else
         sleep(60); /* pause() not threadsafe */
 #endif



---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org