You are viewing a plain text version of this content. The canonical link for it is here.
Posted to xmlrpc-dev@ws.apache.org by bu...@apache.org on 2002/02/20 21:18:21 UTC

DO NOT REPLY [Bug 6593] New: - Thread Safety & Deadlock prevention

DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://nagoya.apache.org/bugzilla/show_bug.cgi?id=6593>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://nagoya.apache.org/bugzilla/show_bug.cgi?id=6593

Thread Safety & Deadlock prevention

           Summary: Thread Safety & Deadlock prevention
           Product: XML-RPC
           Version: unspecified
          Platform: Sun
        OS/Version: Solaris
            Status: NEW
          Severity: Normal
          Priority: Other
         Component: Source
        AssignedTo: rpc-dev@xml.apache.org
        ReportedBy: ashley.l.raiteri@boeing.com


When a call to shutdown on an instantiated Webserver object is made,
it does not completely exit all threads.  The ThreadGroup [runners] remains
active and alive.  The only thread properly managed by shutdown is the
listener thread itself.  
Below are some recommended changes.

patchversion1 --
******************************************
---Webserver.java v1.5 
+++Webserver.java v1.5.proposed1
@@ -351,7 +351,10 @@
             {
                 serverSocket.close();
                 serverSocket = null;
-            }
+                listener = null;
+                runners = null;
+                keepalive = false;
+            }
              catch (IOException ignore)
              {
              }
@@ -365,6 +368,14 @@
     {
         if (listener != null)
         {
+        try {
+             runners.interrupt();          
+        }
+        catch (Exception ex)
+        {
+          System.err.println (ex);
+           ex.printStackTrace();
+        }
         Thread l = listener;
         listener = null;
         l.interrupt ();
@@ -416,7 +427,7 @@

         public void run ()
         {
-            while (Thread.currentThread() == thread)
+            while (con != null && (Thread.currentThread() == thread))
             {
                 con.run ();
                 count++;
***************************************************
patchversion2 --
******************************************
---Webserver.java v1.5 
+++Webserver.java v1.5.proposed2
@@ -351,7 +351,11 @@
             {
                 serverSocket.close();
                 serverSocket = null;
-            }
+                listener = null;
+                runners = null;
+                keepalive = false;
+            }
              catch (IOException ignore)
              {
              }
@@ -363,7 +367,21 @@
     {
-         if (listener != null)
+         if (runners)
+         {
+           ThreadGroup R = runners;
+           runners = null;
+           try {
+               R.interrupt();          
+           }
+           catch (Exception ex)
+           {
+               System.err.println (ex);
+               ex.printStackTrace();
+           }
+        }    
+        if (listener != null)
         {
            Thread l = listener;
            listener = null;
@@ -416,7 +434,7 @@

         public void run ()
         {
-            while (Thread.currentThread() == thread)
+            while (runners && (Thread.currentThread() == thread))
             {
                 con.run ();
                 count++;
***************************************************