directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r696362 - /directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/handlers/SearchHandler.java
Date Wed, 17 Sep 2008 16:23:14 GMT
Author: elecharny
Date: Wed Sep 17 09:23:14 2008
New Revision: 696362

URL: http://svn.apache.org/viewvc?rev=696362&view=rev
Log:
Fixed a memory leak in the searchHandler class : the requests weren't removed from the session
if we've got an exception or when doing a search for the rootDSE.

Modified:
    directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/handlers/SearchHandler.java

Modified: directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/handlers/SearchHandler.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/handlers/SearchHandler.java?rev=696362&r1=696361&r2=696362&view=diff
==============================================================================
--- directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/handlers/SearchHandler.java
(original)
+++ directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/handlers/SearchHandler.java
Wed Sep 17 09:23:14 2008
@@ -572,6 +572,13 @@
             LOG.debug( "Message received:  {}", req.toString() );
         }
 
+        // A flag set if we have a persistent search
+        boolean isPersistentSearch = false;
+        
+        // A flag set when we've got an exception while processing a
+        // persistent search
+        boolean persistentSearchException = false;
+        
         // add the search request to the registry of outstanding requests for this session
         session.registerOutstandingRequest( req );
 
@@ -586,6 +593,7 @@
             if ( isRootDSESearch( req ) )
             {
                 handleRootDseSearch( session, req );
+                
                 return;
             }
 
@@ -598,9 +606,12 @@
             
             if ( psearchControl != null )
             {
+                // Set the flag to avoid the request being removed
+                // from the session
+                isPersistentSearch = true;
+
                 handlePersistentSearch( session, req, psearchControl );
                 
-                // do not unregister the outstanding request unlike below
                 return;
             }
 
@@ -610,7 +621,6 @@
 
             SearchResponseDone done = doSimpleSearch( session, req );
             session.getIoSession().write( done );
-            session.unregisterOutstandingRequest( req );
         }
         catch ( Exception e )
         {
@@ -631,8 +641,25 @@
                 return;
             }
 
+            // If it was a persistent search and if we had an exception,
+            // we set the flag to remove the request from the session
+            if ( isPersistentSearch )
+            {
+                persistentSearchException = true;
+            }
+            
             handleException( session, req, e );
         }
+        finally 
+        {
+            
+            // remove the request from the session, except if
+            // we didn't got an exception for a Persistent search 
+            if ( !isPersistentSearch || persistentSearchException )
+            {
+                session.unregisterOutstandingRequest( req );
+            }
+        }
     }
 
 



Mime
View raw message