You are viewing a plain text version of this content. The canonical link for it is here.
Posted to server-dev@james.apache.org by ba...@apache.org on 2007/04/25 01:47:30 UTC

svn commit: r532141 - /james/jspf/branches/asynch-jspf/src/main/java/org/apache/james/jspf/impl/DNSServiceXBillImpl.java

Author: bago
Date: Tue Apr 24 16:47:30 2007
New Revision: 532141

URL: http://svn.apache.org/viewvc?view=rev&rev=532141
Log:
Change DNSServiceXBillImpl callback to use a callback thread because it wasn't respecting the contract.
The callback of an asynch method should never be called by the original caller thread.
A better solution could be to use a thread pool, but the dnsjnio implementation will take care of this.
The DNSJava based Staged executor is simply a proof of concept.

Modified:
    james/jspf/branches/asynch-jspf/src/main/java/org/apache/james/jspf/impl/DNSServiceXBillImpl.java

Modified: james/jspf/branches/asynch-jspf/src/main/java/org/apache/james/jspf/impl/DNSServiceXBillImpl.java
URL: http://svn.apache.org/viewvc/james/jspf/branches/asynch-jspf/src/main/java/org/apache/james/jspf/impl/DNSServiceXBillImpl.java?view=diff&rev=532141&r1=532140&r2=532141
==============================================================================
--- james/jspf/branches/asynch-jspf/src/main/java/org/apache/james/jspf/impl/DNSServiceXBillImpl.java (original)
+++ james/jspf/branches/asynch-jspf/src/main/java/org/apache/james/jspf/impl/DNSServiceXBillImpl.java Tue Apr 24 16:47:30 2007
@@ -47,13 +47,13 @@
 public class DNSServiceXBillImpl implements DNSService {
 
     // Set seconds after which we return and TempError
-    private int timeOut = 20;
+    protected int timeOut = 20;
 
     // The logger
-    private Logger log;
+    protected Logger log;
     
     // The record limit for lookups
-    private int recordLimit;
+    protected int recordLimit;
     
     /**
      * Default Constructor
@@ -195,12 +195,27 @@
      * @see org.apache.james.jspf.core.DNSService#getRecordsAsynch(java.lang.String, int, java.lang.Object, org.apache.james.jspf.core.IResponseQueue)
      */
     public void getRecordsAsynch(String hostname, int recordType, Object id,
-            IResponseQueue responsePool) {
+            final IResponseQueue responsePool) {
+        IResponseImpl response;
         try {
-            responsePool.insertResponse(new IResponseImpl(id, getRecords(hostname, recordType)));
+            response = new IResponseImpl(id, getRecords(hostname, recordType));
         } catch (TimeoutException e) {
-            responsePool.insertResponse(new IResponseImpl(id, e));
+            response = new IResponseImpl(id, e);
         }
+        new Thread() {
+
+            private IResponseImpl response;
+
+            public void run() {
+                responsePool.insertResponse(response);
+            }
+
+            public Thread setResponse(IResponseImpl response) {
+                this.response = response;
+                return this;
+            }
+            
+        }.setResponse(response).start();
 
     }
 



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


Re: svn commit: r532141 - /james/jspf/branches/asynch-jspf/src/main/java/org/apache/james/jspf/impl/DNSServiceXBillImpl.java

Posted by Norman Maurer <no...@apache.org>.
Hi Stefano,

just to let you know.. The race condition / deadlock is still in the place.

bye
Norman

bago@apache.org schrieb:

> Author: bago
> Date: Tue Apr 24 16:47:30 2007
> New Revision: 532141
>
> URL: http://svn.apache.org/viewvc?view=rev&rev=532141
> Log:
> Change DNSServiceXBillImpl callback to use a callback thread because it wasn't respecting the contract.
> The callback of an asynch method should never be called by the original caller thread.
> A better solution could be to use a thread pool, but the dnsjnio implementation will take care of this.
> The DNSJava based Staged executor is simply a proof of concept.
>
> Modified:
>     james/jspf/branches/asynch-jspf/src/main/java/org/apache/james/jspf/impl/DNSServiceXBillImpl.java
>
> Modified: james/jspf/branches/asynch-jspf/src/main/java/org/apache/james/jspf/impl/DNSServiceXBillImpl.java
> URL: http://svn.apache.org/viewvc/james/jspf/branches/asynch-jspf/src/main/java/org/apache/james/jspf/impl/DNSServiceXBillImpl.java?view=diff&rev=532141&r1=532140&r2=532141
> ==============================================================================
> --- james/jspf/branches/asynch-jspf/src/main/java/org/apache/james/jspf/impl/DNSServiceXBillImpl.java (original)
> +++ james/jspf/branches/asynch-jspf/src/main/java/org/apache/james/jspf/impl/DNSServiceXBillImpl.java Tue Apr 24 16:47:30 2007
> @@ -47,13 +47,13 @@
>  public class DNSServiceXBillImpl implements DNSService {
>  
>      // Set seconds after which we return and TempError
> -    private int timeOut = 20;
> +    protected int timeOut = 20;
>  
>      // The logger
> -    private Logger log;
> +    protected Logger log;
>      
>      // The record limit for lookups
> -    private int recordLimit;
> +    protected int recordLimit;
>      
>      /**
>       * Default Constructor
> @@ -195,12 +195,27 @@
>       * @see org.apache.james.jspf.core.DNSService#getRecordsAsynch(java.lang.String, int, java.lang.Object, org.apache.james.jspf.core.IResponseQueue)
>       */
>      public void getRecordsAsynch(String hostname, int recordType, Object id,
> -            IResponseQueue responsePool) {
> +            final IResponseQueue responsePool) {
> +        IResponseImpl response;
>          try {
> -            responsePool.insertResponse(new IResponseImpl(id, getRecords(hostname, recordType)));
> +            response = new IResponseImpl(id, getRecords(hostname, recordType));
>          } catch (TimeoutException e) {
> -            responsePool.insertResponse(new IResponseImpl(id, e));
> +            response = new IResponseImpl(id, e);
>          }
> +        new Thread() {
> +
> +            private IResponseImpl response;
> +
> +            public void run() {
> +                responsePool.insertResponse(response);
> +            }
> +
> +            public Thread setResponse(IResponseImpl response) {
> +                this.response = response;
> +                return this;
> +            }
> +            
> +        }.setResponse(response).start();
>  
>      }
>  
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
> For additional commands, e-mail: server-dev-help@james.apache.org
>
>
> !DSPAM:1,462e9750324325014519403!
>
>
>   


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