|
From: <wol...@us...> - 2004-03-08 11:45:36
|
Update of /cvsroot/exist/eXist-1.0/src/org/exist/storage In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22257/src/org/exist/storage Modified Files: BrokerPool.java DBBroker.java Log Message: * class BrokerPool now detects if a thread does already hold a broker object and increments a reference count instead of returning a new object. Otherwise, deadlock situations could occurr. * documentCache in RpcConnection should be cleared if changes have been made to the database. * implemented missing getMembersAsResource method in RemoteResourceSet. Index: BrokerPool.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/storage/BrokerPool.java,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** BrokerPool.java 5 Mar 2004 16:15:47 -0000 1.18 --- BrokerPool.java 8 Mar 2004 11:21:21 -0000 1.19 *************** *** 22,26 **** --- 22,28 ---- import java.util.ArrayList; + import java.util.HashMap; import java.util.Iterator; + import java.util.Map; import java.util.Stack; import java.util.TreeMap; *************** *** 160,163 **** --- 162,166 ---- private int brokers = 0; private Stack pool = new Stack(); + private Map threads = new HashMap(); private org.exist.security.SecurityManager secManager = null; private String instanceId; *************** *** 236,239 **** --- 239,248 ---- if (!isInstanceConfigured()) throw new EXistException("database instance is not available"); + DBBroker broker = (DBBroker)threads.get(Thread.currentThread()); + if(broker != null) { + // the thread already holds a reference to a broker object. + broker.incReferenceCount(); + return broker; + } if (pool.isEmpty()) { if (brokers < max) *************** *** 248,252 **** } } ! DBBroker broker = (DBBroker) pool.pop(); this.notifyAll(); return broker; --- 257,263 ---- } } ! broker = (DBBroker) pool.pop(); ! threads.put(Thread.currentThread(), broker); ! broker.incReferenceCount(); this.notifyAll(); return broker; *************** *** 312,315 **** --- 323,332 ---- if (broker == null) return; + broker.decReferenceCount(); + if(broker.getReferenceCount() > 0) { + LOG.debug("Broker still has references. Keep it."); + return; + } + threads.remove(Thread.currentThread()); if (pool.contains(broker)) { return; Index: DBBroker.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/storage/DBBroker.java,v retrieving revision 1.21 retrieving revision 1.22 diff -C2 -d -r1.21 -r1.22 *** DBBroker.java 29 Jan 2004 15:06:48 -0000 1.21 --- DBBroker.java 8 Mar 2004 11:21:21 -0000 1.22 *************** *** 82,85 **** --- 82,87 ---- protected SymbolTable symbols = null; protected User user = null; + + private int referenceCount = 0; protected void saveSymbols() throws EXistException { *************** *** 551,554 **** --- 553,557 ---- public void readDocumentMetadata(final DocumentImpl doc) { } + /** * get all the documents in this database matching the given document-type's name.@param doctypeName Description of the Parameter@param user Description of the Parameter@return The documentsByDoctype value *************** *** 558,560 **** --- 561,574 ---- DocumentSet result); + public int getReferenceCount() { + return referenceCount; + } + + public void incReferenceCount() { + ++referenceCount; + } + + public void decReferenceCount() { + --referenceCount; + } } \ No newline at end of file |