You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mina.apache.org by lg...@apache.org on 2016/02/15 17:51:23 UTC
[5/6] mina-sshd git commit: Use the randomizer instance as lock for
some internal values instead of the "master" lock
Use the randomizer instance as lock for some internal values instead of the "master" lock
Project: http://git-wip-us.apache.org/repos/asf/mina-sshd/repo
Commit: http://git-wip-us.apache.org/repos/asf/mina-sshd/commit/711e01a1
Tree: http://git-wip-us.apache.org/repos/asf/mina-sshd/tree/711e01a1
Diff: http://git-wip-us.apache.org/repos/asf/mina-sshd/diff/711e01a1
Branch: refs/heads/master
Commit: 711e01a1e9041692a84d33d98e3d8d19aa919ed8
Parents: 823540d
Author: Lyor Goldstein <ly...@gmail.com>
Authored: Mon Feb 15 18:51:41 2016 +0200
Committer: Lyor Goldstein <ly...@gmail.com>
Committed: Mon Feb 15 18:51:41 2016 +0200
----------------------------------------------------------------------
.../apache/sshd/common/session/AbstractSession.java | 15 ++++++++++-----
1 file changed, 10 insertions(+), 5 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/711e01a1/sshd-core/src/main/java/org/apache/sshd/common/session/AbstractSession.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/common/session/AbstractSession.java b/sshd-core/src/main/java/org/apache/sshd/common/session/AbstractSession.java
index 8455313..daaa0c1 100644
--- a/sshd-core/src/main/java/org/apache/sshd/common/session/AbstractSession.java
+++ b/sshd-core/src/main/java/org/apache/sshd/common/session/AbstractSession.java
@@ -392,7 +392,7 @@ public abstract class AbstractSession extends AbstractKexFactoryManager implemen
* Refresh whatever internal configuration is not {@code final}
*/
protected void refreshConfiguration() {
- synchronized (lock) {
+ synchronized (random) {
// re-keying configuration
maxRekeyBytes = PropertyResolverUtils.getLongProperty(this, FactoryManager.REKEY_BYTES_LIMIT, maxRekeyBytes);
maxRekeyInterval = PropertyResolverUtils.getLongProperty(this, FactoryManager.REKEY_TIME_LIMIT, maxRekeyInterval);
@@ -915,7 +915,7 @@ public abstract class AbstractSession extends AbstractKexFactoryManager implemen
ignoreBuf.putInt(ignoreDataLen);
int wpos = ignoreBuf.wpos();
- synchronized (lock) {
+ synchronized (random) {
random.fill(ignoreBuf.array(), wpos, ignoreDataLen);
}
ignoreBuf.wpos(wpos + ignoreDataLen);
@@ -954,7 +954,7 @@ public abstract class AbstractSession extends AbstractKexFactoryManager implemen
return 0;
}
- synchronized (lock) {
+ synchronized (random) {
ignorePacketsCount.set(calculateNextIgnorePacketCount(random, ignorePacketsFrequency, ignorePacketsVariance));
return ignorePacketDataLength + random.random(ignorePacketDataLength);
}
@@ -1135,7 +1135,10 @@ public abstract class AbstractSession extends AbstractKexFactoryManager implemen
buffer.putByte((byte) pad);
// Fill padding
buffer.wpos(off + oldLen + SshConstants.SSH_PACKET_HEADER_LEN + pad);
- random.fill(buffer.array(), buffer.wpos() - pad, pad);
+ synchronized (random) {
+ random.fill(buffer.array(), buffer.wpos() - pad, pad);
+ }
+
// Compute mac
if (outMac != null) {
int macSize = outMac.getBlockSize();
@@ -1398,7 +1401,9 @@ public abstract class AbstractSession extends AbstractKexFactoryManager implemen
Buffer buffer = createBuffer(SshConstants.SSH_MSG_KEXINIT);
int p = buffer.wpos();
buffer.wpos(p + SshConstants.MSG_KEX_COOKIE_SIZE);
- random.fill(buffer.array(), p, SshConstants.MSG_KEX_COOKIE_SIZE);
+ synchronized (random) {
+ random.fill(buffer.array(), p, SshConstants.MSG_KEX_COOKIE_SIZE);
+ }
if (log.isTraceEnabled()) {
log.trace("sendKexInit(" + toString() + ") cookie=" + BufferUtils.toHex(buffer.array(), p, SshConstants.MSG_KEX_COOKIE_SIZE, ':'));
}