Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
home:Ledest:erlang:24
erlang
2835-jinterface-Avoid-0-creation-value.patch
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File 2835-jinterface-Avoid-0-creation-value.patch of Package erlang
From 80090b80a48f01243c8de41709d4caa5fe4d463d Mon Sep 17 00:00:00 2001 From: Sverker Eriksson <sverker@erlang.org> Date: Tue, 2 Nov 2021 19:42:12 +0100 Subject: [PATCH 5/8] jinterface: Avoid 0-creation value --- .../ericsson/otp/erlang/AbstractConnection.java | 14 +++++++------- .../com/ericsson/otp/erlang/AbstractNode.java | 9 ++++++++- .../java_src/com/ericsson/otp/erlang/OtpEpmd.java | 2 +- .../com/ericsson/otp/erlang/OtpErlangPid.java | 5 ++--- .../com/ericsson/otp/erlang/OtpErlangPort.java | 4 ++-- .../com/ericsson/otp/erlang/OtpErlangRef.java | 7 +++---- .../com/ericsson/otp/erlang/OtpLocalNode.java | 6 +++--- 7 files changed, 26 insertions(+), 21 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 db56478667..75b538f085 100644 --- a/lib/jinterface/java_src/com/ericsson/otp/erlang/AbstractConnection.java +++ b/lib/jinterface/java_src/com/ericsson/otp/erlang/AbstractConnection.java @@ -1062,7 +1062,7 @@ public abstract class AbstractConnection extends Thread { + port); } final int send_name_tag = sendName(peer.distChoose, localNode.flags, - localNode.creation); + localNode.creation()); recvStatus(); final int her_challenge = recvChallenge(); final byte[] our_digest = genDigest(her_challenge, @@ -1187,14 +1187,14 @@ public abstract class AbstractConnection extends Thread { obuf.write1('c'); final int flagsHigh = (int)(localNode.flags >> 32); obuf.write4BE(flagsHigh); - obuf.write4BE(localNode.creation); + obuf.write4BE(localNode.creation()); obuf.writeToAndFlush(socket.getOutputStream()); if (traceLevel >= handshakeThreshold) { System.out.println("-> " + "HANDSHAKE sendComplement" + " flagsHigh=" + flagsHigh + - " creation=" + localNode.creation); + " creation=" + localNode.creation()); } } } @@ -1218,7 +1218,7 @@ public abstract class AbstractConnection extends Thread { obuf.write1('N'); obuf.write8BE(our_flags); obuf.write4BE(challenge); - obuf.write4BE(localNode.creation); + obuf.write4BE(localNode.creation()); obuf.write2BE(str.length()); obuf.write(str.getBytes()); } @@ -1273,7 +1273,7 @@ public abstract class AbstractConnection extends Thread { apeer.flags = ibuf.read8BE(); if ((apeer.flags & AbstractNode.dFlagHandshake23) == 0) throw new IOException("Missing DFLAG_HANDSHAKE_23"); - apeer.creation = ibuf.read4BE(); + apeer.setCreation(ibuf.read4BE()); int namelen = ibuf.read2BE(); tmpname = new byte[namelen]; ibuf.readN(tmpname); @@ -1334,7 +1334,7 @@ public abstract class AbstractConnection extends Thread { if ((peer.flags & AbstractNode.dFlagHandshake23) == 0) throw new IOException("New challenge missing DFLAG_HANDHAKE_23"); challenge = ibuf.read4BE(); - peer.creation = ibuf.read4BE(); + peer.setCreation(ibuf.read4BE()); namelen = ibuf.read2BE(); break; default: @@ -1383,7 +1383,7 @@ public abstract class AbstractConnection extends Thread { final long flagsHigh = ibuf.read4BE(); peer.flags |= flagsHigh << 32; - peer.creation = ibuf.read4BE(); + peer.setCreation(ibuf.read4BE()); } catch (final OtpErlangDecodeException e) { throw new IOException("Handshake failed - not enough data"); 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 13ee63cb42..3955da5d83 100644 --- a/lib/jinterface/java_src/com/ericsson/otp/erlang/AbstractNode.java +++ b/lib/jinterface/java_src/com/ericsson/otp/erlang/AbstractNode.java @@ -118,7 +118,7 @@ public class AbstractNode implements OtpTransportFactory { int proto = 0; // tcp/ip int distHigh = 6; int distLow = 5; // Cannot talk to nodes before R6 - int creation = 0; + private int creation = 0x710000; long flags = dFlagExtendedReferences | dFlagExtendedPidsPorts | dFlagBitBinaries | dFlagNewFloats | dFlagFunTags | dflagNewFunTags | dFlagUtf8Atoms | dFlagMapTag @@ -285,6 +285,13 @@ public class AbstractNode implements OtpTransportFactory { return creation; } + void setCreation(int cr) throws OtpErlangDecodeException { + if (cr == 0) { + throw new OtpErlangDecodeException("Node creation 0 not allowed"); + } + this.creation = cr; + } + /** * Set the authorization cookie used by this node. * diff --git a/lib/jinterface/java_src/com/ericsson/otp/erlang/OtpEpmd.java b/lib/jinterface/java_src/com/ericsson/otp/erlang/OtpEpmd.java index 008ee9727e..fc0dc8827c 100644 --- a/lib/jinterface/java_src/com/ericsson/otp/erlang/OtpEpmd.java +++ b/lib/jinterface/java_src/com/ericsson/otp/erlang/OtpEpmd.java @@ -326,7 +326,7 @@ public class OtpEpmd { if (response == ALIVE2_RESP || response == ALIVE2_X_RESP) { final int result = ibuf.read1(); if (result == 0) { - node.creation = (response == ALIVE2_RESP + node.setCreation(response == ALIVE2_RESP ? ibuf.read2BE() : ibuf.read4BE()); if (traceLevel >= traceThreshold) { System.out.println("<- OK"); diff --git a/lib/jinterface/java_src/com/ericsson/otp/erlang/OtpErlangPid.java b/lib/jinterface/java_src/com/ericsson/otp/erlang/OtpErlangPid.java index 3abdf9535f..0cab076227 100644 --- a/lib/jinterface/java_src/com/ericsson/otp/erlang/OtpErlangPid.java +++ b/lib/jinterface/java_src/com/ericsson/otp/erlang/OtpErlangPid.java @@ -85,12 +85,11 @@ public class OtpErlangPid extends OtpErlangObject implements Comparable<Object> * used. * * @param creation - * yet another arbitrary number. Ony the low order 2 bits will - * be used. + * node incarnation number. Avoid values 0 to 3. */ public OtpErlangPid(final String node, final int id, final int serial, final int creation) { - this(OtpExternal.pidTag, node, id, serial, creation); + this(OtpExternal.newPidTag, node, id, serial, creation); } /** diff --git a/lib/jinterface/java_src/com/ericsson/otp/erlang/OtpErlangPort.java b/lib/jinterface/java_src/com/ericsson/otp/erlang/OtpErlangPort.java index 320603494a..476addb086 100644 --- a/lib/jinterface/java_src/com/ericsson/otp/erlang/OtpErlangPort.java +++ b/lib/jinterface/java_src/com/ericsson/otp/erlang/OtpErlangPort.java @@ -77,10 +77,10 @@ public class OtpErlangPort extends OtpErlangObject { * an arbitrary number. Only the low order 28 bits will be used. * * @param creation - * another arbitrary number. Only the low order 2 bits will be used. + * node incarnation number. Avoid values 0 to 3. */ public OtpErlangPort(final String node, final long id, final int creation) { - this(OtpExternal.portTag, node, id, creation); + this(OtpExternal.newPortTag, node, id, creation); } /** diff --git a/lib/jinterface/java_src/com/ericsson/otp/erlang/OtpErlangRef.java b/lib/jinterface/java_src/com/ericsson/otp/erlang/OtpErlangRef.java index ce52d0c395..6fba5dd4a2 100644 --- a/lib/jinterface/java_src/com/ericsson/otp/erlang/OtpErlangRef.java +++ b/lib/jinterface/java_src/com/ericsson/otp/erlang/OtpErlangRef.java @@ -106,12 +106,11 @@ public class OtpErlangRef extends OtpErlangObject { * three numbers will be read from the array. * * @param creation - * another arbitrary number. Only the low order 2 bits will be - * used. + * node incarnation number. Avoid values 0 to 3. */ public OtpErlangRef(final String node, final int[] ids, final int creation) { - this(OtpExternal.newRefTag, node, ids, creation); - } + this(OtpExternal.newerRefTag, node, ids, creation); + } /** * Create a new(er) style Erlang ref from its components. diff --git a/lib/jinterface/java_src/com/ericsson/otp/erlang/OtpLocalNode.java b/lib/jinterface/java_src/com/ericsson/otp/erlang/OtpLocalNode.java index 6f896aab9f..9f2587e7a2 100644 --- a/lib/jinterface/java_src/com/ericsson/otp/erlang/OtpLocalNode.java +++ b/lib/jinterface/java_src/com/ericsson/otp/erlang/OtpLocalNode.java @@ -114,7 +114,7 @@ public class OtpLocalNode extends AbstractNode { */ public synchronized OtpErlangPid createPid() { final OtpErlangPid p = new OtpErlangPid(node, pidCount, serial, - creation); + creation()); pidCount++; if (pidCount > 0x7fff) { @@ -139,7 +139,7 @@ public class OtpLocalNode extends AbstractNode { * @return an Erlang port. */ public synchronized OtpErlangPort createPort() { - final OtpErlangPort p = new OtpErlangPort(node, portCount, creation); + final OtpErlangPort p = new OtpErlangPort(node, portCount, creation()); portCount++; if (portCount > 0xfffffff) { /* 28 bits */ @@ -158,7 +158,7 @@ public class OtpLocalNode extends AbstractNode { * @return an Erlang reference. */ public synchronized OtpErlangRef createRef() { - final OtpErlangRef r = new OtpErlangRef(node, refId, creation); + final OtpErlangRef r = new OtpErlangRef(node, refId, creation()); // increment ref ids (3 ints: 18 + 32 + 32 bits) refId[0]++; -- 2.31.1
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor