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 pg...@apache.org on 2002/10/26 05:57:23 UTC

cvs commit: jakarta-james/src/java/org/apache/james/util/mordred JdbcDataSource.java

pgoldstein    2002/10/25 20:57:23

  Modified:    src/java/org/apache/james/util/mordred JdbcDataSource.java
  Log:
  Changed the JDBC connection pool code to set the thread state to normal
  before releasing the thread back to the pool.
  
  Revision  Changes    Path
  1.18      +36 -32    jakarta-james/src/java/org/apache/james/util/mordred/JdbcDataSource.java
  
  Index: JdbcDataSource.java
  ===================================================================
  RCS file: /home/cvs/jakarta-james/src/java/org/apache/james/util/mordred/JdbcDataSource.java,v
  retrieving revision 1.17
  retrieving revision 1.18
  diff -u -r1.17 -r1.18
  --- JdbcDataSource.java	4 Oct 2002 08:17:49 -0000	1.17
  +++ JdbcDataSource.java	26 Oct 2002 03:57:23 -0000	1.18
  @@ -379,40 +379,44 @@
        * and checks whether connections have been checked out for too long, killing them.
        */
       public void run() {
  -        while(reaperActive) {
  -            for(int i = 0; i < pool.size(); i++) {
  -                PoolConnEntry entry = (PoolConnEntry)pool.elementAt(i);
  -                long age            = System.currentTimeMillis() - entry.getLastActivity();
  -                synchronized(entry) {
  -                    if((entry.getStatus() == PoolConnEntry.ACTIVE) &&
  -                       (age > ACTIVE_CONN_TIME_LIMIT)) {
  -                        StringBuffer logBuffer =
  -                            new StringBuffer(128)
  -                                    .append(" ***** connection ")
  -                                    .append(entry.getId())
  -                                    .append(" is way too old: ")
  -                                    .append(age)
  -                                    .append(" > ")
  -                                    .append(ACTIVE_CONN_TIME_LIMIT);
  -                        getLogger().info(logBuffer.toString());
  -                        // This connection is way too old...
  -                        // kill it no matter what
  -                        finalizeEntry(entry);
  -                        continue;
  -                    }
  -                    if((entry.getStatus() == PoolConnEntry.AVAILABLE) &&
  -                       (age > CONN_IDLE_LIMIT)) {
  -                        //We've got a connection that's too old... kill it
  -                        finalizeEntry(entry);
  -                        continue;
  +        try {
  +            while(reaperActive) {
  +                for(int i = 0; i < pool.size(); i++) {
  +                    PoolConnEntry entry = (PoolConnEntry)pool.elementAt(i);
  +                    long age            = System.currentTimeMillis() - entry.getLastActivity();
  +                    synchronized(entry) {
  +                        if((entry.getStatus() == PoolConnEntry.ACTIVE) &&
  +                           (age > ACTIVE_CONN_TIME_LIMIT)) {
  +                            StringBuffer logBuffer =
  +                                new StringBuffer(128)
  +                                        .append(" ***** connection ")
  +                                        .append(entry.getId())
  +                                        .append(" is way too old: ")
  +                                        .append(age)
  +                                        .append(" > ")
  +                                        .append(ACTIVE_CONN_TIME_LIMIT);
  +                            getLogger().info(logBuffer.toString());
  +                            // This connection is way too old...
  +                            // kill it no matter what
  +                            finalizeEntry(entry);
  +                            continue;
  +                        }
  +                        if((entry.getStatus() == PoolConnEntry.AVAILABLE) &&
  +                           (age > CONN_IDLE_LIMIT)) {
  +                            //We've got a connection that's too old... kill it
  +                            finalizeEntry(entry);
  +                            continue;
  +                        }
                       }
                   }
  +                try {
  +                    // Check for activity every 5 seconds
  +                    Thread.sleep(5000L);
  +                } catch(InterruptedException ex) {
  +                }
               }
  -            try {
  -                // Check for activity every 5 seconds
  -                Thread.sleep(5000L);
  -            } catch(InterruptedException ex) {
  -            }
  +        } finally {
  +            Thread.currentThread().interrupted();
           }
       }
   
  
  
  

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>