You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by ma...@apache.org on 2019/05/23 09:59:20 UTC
[tomcat] 03/05: Fix
https://bz.apache.org/bugzilla/show_bug.cgi?id=62841 BackupManager
This is an automated email from the ASF dual-hosted git repository.
markt pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/tomcat.git
commit bcf1b79959febb21dbc947d06873251f3a02d758
Author: Mark Thomas <ma...@apache.org>
AuthorDate: Tue May 21 22:35:16 2019 +0100
Fix https://bz.apache.org/bugzilla/show_bug.cgi?id=62841 BackupManager
Expand the fix to the BackupManager by refactoring the locking into the
DeltaSession and ensuring that the session is not locked during
serialization.
---
.../apache/catalina/ha/session/DeltaSession.java | 51 +++++++++++++++++-----
1 file changed, 41 insertions(+), 10 deletions(-)
diff --git a/java/org/apache/catalina/ha/session/DeltaSession.java b/java/org/apache/catalina/ha/session/DeltaSession.java
index 07b4cca..d9afe90 100644
--- a/java/org/apache/catalina/ha/session/DeltaSession.java
+++ b/java/org/apache/catalina/ha/session/DeltaSession.java
@@ -138,12 +138,29 @@ public class DeltaSession extends StandardSession implements Externalizable,Clus
*/
@Override
public byte[] getDiff() throws IOException {
- lockInternal();
- try {
- return getDeltaRequest().serialize();
- } finally{
- unlockInternal();
+ SynchronizedStack<DeltaRequest> deltaRequestPool = null;
+ DeltaRequest newDeltaRequest = null;
+
+ if (manager instanceof ClusterManagerBase) {
+ deltaRequestPool = ((ClusterManagerBase) manager).getDeltaRequestPool();
+ newDeltaRequest = deltaRequestPool.pop();
}
+ if (newDeltaRequest == null) {
+ newDeltaRequest = new DeltaRequest();
+ }
+
+ DeltaRequest oldDeltaRequest = replaceDeltaRequest(newDeltaRequest);
+
+ byte[] result = oldDeltaRequest.serialize();
+
+ if (deltaRequestPool != null) {
+ // Only need to reset the old request if it is going to be pooled.
+ // Otherwise let GC do its thing.
+ oldDeltaRequest.reset();
+ deltaRequestPool.push(oldDeltaRequest);
+ }
+
+ return result;
}
public ClassLoader[] getClassLoaders() {
@@ -183,32 +200,46 @@ public class DeltaSession extends StandardSession implements Externalizable,Clus
}
/**
- * Resets the current diff state and resets the dirty flag
+ * {@inheritDoc}
+ * <p>
+ * This implementation is a NO-OP. The diff is reset in {@link #getDiff()}.
*/
@Override
public void resetDiff() {
resetDeltaRequest();
}
+ /**
+ * {@inheritDoc}
+ * <p>
+ * This implementation is a NO-OP. Any required locking takes place in the
+ * methods that make modifications.
+ */
@Override
public void lock() {
- lockInternal();
+ // NO-OP
}
+ /**
+ * {@inheritDoc}
+ * <p>
+ * This implementation is a NO-OP. Any required unlocking takes place in the
+ * methods that make modifications.
+ */
@Override
public void unlock() {
- unlockInternal();
+ // NO-OP
}
/**
- * Lock during serialization
+ * Lock during serialization.
*/
private void lockInternal() {
diffLock.lock();
}
/**
- * Unlock after serialization
+ * Unlock after serialization.
*/
private void unlockInternal() {
diffLock.unlock();
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org