diff options
| author | Björn Gustavsson <bjorn@erlang.org> | 2021-06-10 09:44:56 +0200 |
|---|---|---|
| committer | Björn Gustavsson <bjorn@erlang.org> | 2021-06-23 08:22:14 +0200 |
| commit | 318ed4605ccf4dc402623c6cd94ddb8547cb9875 (patch) | |
| tree | 443f73bd23f51d1d03bf0c88c63f55f24f7b0fd5 /lib/jinterface/java_src/com | |
| parent | b94fde09ec9be03cc0a17e6d16a397f18680eb76 (diff) | |
| download | erlang-318ed4605ccf4dc402623c6cd94ddb8547cb9875.tar.gz | |
Introduce a scheme for reusing mandatory distribution flags
During distribution connect setup between two nodes, the nodes exchange
flags words encoding their capabilities. The connection setup is aborted
if one of the node lacks a capability that the other node requires.
In version 5 of the protocol (introduced in OTP R6), there are 32
possible capabilities (each encoded in a single bit). Since it seemed
that we would soon run out of capabilitiy bits, protocol version 6
(introduced in OTP 23) expanded the number of possible capability bits
to 64.
To avoid having to extend the number of capabilites yet again from 64
to 128 in some future release, this commit introduces a scheme to
allow reusing the bit numbers for capabilities that are now
mandatory. The scheme is described in lib/kernel/include/dist.hrl.
There are 10 mandatory capability bits as of OTP 25. This scheme will
allow reusing 9 of those capability bits as early as in OTP 27.
Diffstat (limited to 'lib/jinterface/java_src/com')
| -rw-r--r-- | lib/jinterface/java_src/com/ericsson/otp/erlang/AbstractConnection.java | 8 | ||||
| -rw-r--r-- | lib/jinterface/java_src/com/ericsson/otp/erlang/AbstractNode.java | 13 |
2 files changed, 17 insertions, 4 deletions
diff --git a/lib/jinterface/java_src/com/ericsson/otp/erlang/AbstractConnection.java b/lib/jinterface/java_src/com/ericsson/otp/erlang/AbstractConnection.java index 6e58794b43..db56478667 100644 --- a/lib/jinterface/java_src/com/ericsson/otp/erlang/AbstractConnection.java +++ b/lib/jinterface/java_src/com/ericsson/otp/erlang/AbstractConnection.java @@ -1283,6 +1283,10 @@ public abstract class AbstractConnection extends Thread { throw new IOException("Unknown remote node type"); } + if ((apeer.flags & AbstractNode.dFlagMandatory25Digest) != 0) { + apeer.flags |= AbstractNode.mandatoryFlags25; + } + if ((apeer.flags & AbstractNode.mandatoryFlags) != AbstractNode.mandatoryFlags) { throw new IOException( "Handshake failed - peer cannot handle all mandatory capabilities"); @@ -1344,6 +1348,10 @@ public abstract class AbstractConnection extends Thread { "Handshake failed - peer has wrong name: " + hisname); } + if ((peer.flags & AbstractNode.dFlagMandatory25Digest) != 0) { + peer.flags |= AbstractNode.mandatoryFlags25; + } + if ((peer.flags & AbstractNode.mandatoryFlags) != AbstractNode.mandatoryFlags) { throw new IOException( "Handshake failed - peer cannot handle all mandatory capabilities"); diff --git a/lib/jinterface/java_src/com/ericsson/otp/erlang/AbstractNode.java b/lib/jinterface/java_src/com/ericsson/otp/erlang/AbstractNode.java index 08bb63db73..13ee63cb42 100644 --- a/lib/jinterface/java_src/com/ericsson/otp/erlang/AbstractNode.java +++ b/lib/jinterface/java_src/com/ericsson/otp/erlang/AbstractNode.java @@ -95,11 +95,11 @@ public class AbstractNode implements OtpTransportFactory { static final int dFlagBigCreation = 0x40000; static final int dFlagHandshake23 = 0x1000000; static final int dFlagUnlinkId = 0x2000000; + static final int dFlagMandatory25Digest = 0x4000000; static final long dFlagV4PidsRefs = 0x4L << 32; - /* Mandatory flags for distribution. Keep them in sync with - DFLAG_DIST_MANDATORY in erts/emulator/beam/dist.h. */ - static final long mandatoryFlags = dFlagExtendedReferences + /* Mandatory flags in OTP 25. */ + static final long mandatoryFlags25 = dFlagExtendedReferences | dFlagFunTags | dFlagExtendedPidsPorts | dFlagUtf8Atoms @@ -110,6 +110,10 @@ public class AbstractNode implements OtpTransportFactory { | dFlagExportPtrTag | dFlagBitBinaries; + /* Mandatory flags for distribution. Keep them in sync with + DFLAG_DIST_MANDATORY in erts/emulator/beam/dist.h. */ + static final long mandatoryFlags = mandatoryFlags25; + int ntype = NTYPE_R6; int proto = 0; // tcp/ip int distHigh = 6; @@ -118,7 +122,8 @@ public class AbstractNode implements OtpTransportFactory { long flags = mandatoryFlags | dFlagHandshake23 | dFlagUnlinkId - | dFlagV4PidsRefs; + | dFlagV4PidsRefs + | dFlagMandatory25Digest; /* initialize hostname and default cookie */ static { |
