diff options
author | Sverker Eriksson <[email protected]> | 2019-04-11 14:06:39 +0200 |
---|---|---|
committer | Sverker Eriksson <[email protected]> | 2019-04-11 14:06:39 +0200 |
commit | 508738f4dcd3c8c83fffb55c2ad5c365f80dc7c4 (patch) | |
tree | 6617cc0ba929f7b736be2750dfbb4e0da4ffac09 /lib/erl_interface | |
parent | 0e635324b19dd203454f41b41df7a7bb799bc40a (diff) | |
parent | 1ba8bf12eddb363481b1b5856af7c4d7c3313e52 (diff) | |
download | otp-508738f4dcd3c8c83fffb55c2ad5c365f80dc7c4.tar.gz otp-508738f4dcd3c8c83fffb55c2ad5c365f80dc7c4.tar.bz2 otp-508738f4dcd3c8c83fffb55c2ad5c365f80dc7c4.zip |
Merge branch 'sverker/revert-big-creation'
* sverker/revert-big-creation:
Revert "erts: Make DFLAG_BIG_CREATION mandatory"
Revert "erts: Remove old encoding of pids, ports and refs"
Revert "erl_interface: Remove old encoding of pid,port,refs"
Revert "epmd: Support 32-bit creation values in local node"
Revert "jinterface: Remove old encoding of pid,port,refs"
Revert "erl_interface: Support 32-bit creation local cnode"
Revert "erts: Document new EPMD response ALIVE2_X_RESP"
Diffstat (limited to 'lib/erl_interface')
-rw-r--r-- | lib/erl_interface/src/connect/ei_connect.c | 4 | ||||
-rw-r--r-- | lib/erl_interface/src/encode/encode_pid.c | 11 | ||||
-rw-r--r-- | lib/erl_interface/src/encode/encode_port.c | 11 | ||||
-rw-r--r-- | lib/erl_interface/src/encode/encode_ref.c | 10 | ||||
-rw-r--r-- | lib/erl_interface/src/epmd/ei_epmd.h | 5 | ||||
-rw-r--r-- | lib/erl_interface/src/epmd/epmd_publish.c | 28 | ||||
-rw-r--r-- | lib/erl_interface/src/prog/erl_call.c | 3 | ||||
-rw-r--r-- | lib/erl_interface/test/erl_eterm_SUITE.erl | 10 |
8 files changed, 42 insertions, 40 deletions
diff --git a/lib/erl_interface/src/connect/ei_connect.c b/lib/erl_interface/src/connect/ei_connect.c index be7a2a6b0e..7a304e6d4f 100644 --- a/lib/erl_interface/src/connect/ei_connect.c +++ b/lib/erl_interface/src/connect/ei_connect.c @@ -659,7 +659,7 @@ int ei_connect_xinit_ussi(ei_cnode* ec, const char *thishostname, return ERL_ERROR; } - ec->creation = creation; + ec->creation = creation & 0x3; /* 2 bits */ if (cookie) { if (strlen(cookie) >= sizeof(ec->ei_connect_cookie)) { @@ -698,7 +698,7 @@ int ei_connect_xinit_ussi(ei_cnode* ec, const char *thishostname, strcpy(ec->self.node,thisnodename); ec->self.num = 0; ec->self.serial = 0; - ec->self.creation = creation; + ec->self.creation = creation & 0x3; /* 2 bits */ ec->cbs = cbs; ec->setup_context = setup_context; diff --git a/lib/erl_interface/src/encode/encode_pid.c b/lib/erl_interface/src/encode/encode_pid.c index 0dfdb16372..d14746b40f 100644 --- a/lib/erl_interface/src/encode/encode_pid.c +++ b/lib/erl_interface/src/encode/encode_pid.c @@ -25,6 +25,7 @@ int ei_encode_pid(char *buf, int *index, const erlang_pid *p) { char* s = buf + *index; + const char tag = (p->creation > 3) ? ERL_NEW_PID_EXT : ERL_PID_EXT; ++(*index); /* skip ERL_PID_EXT */ if (ei_encode_atom_len_as(buf, index, p->node, strlen(p->node), @@ -32,17 +33,21 @@ int ei_encode_pid(char *buf, int *index, const erlang_pid *p) return -1; if (buf) { - put8(s, ERL_NEW_PID_EXT); + put8(s, tag); s = buf + *index; /* now the integers */ put32be(s,p->num & 0x7fff); /* 15 bits */ put32be(s,p->serial & 0x1fff); /* 13 bits */ - put32be(s, p->creation); /* 32 bits */ + if (tag == ERL_PID_EXT) { + put8(s,(p->creation & 0x03)); /* 2 bits */ + } else { + put32be(s, p->creation); /* 32 bits */ + } } - *index += 4 + 4 + 4; + *index += 4 + 4 + (tag == ERL_PID_EXT ? 1 : 4); return 0; } diff --git a/lib/erl_interface/src/encode/encode_port.c b/lib/erl_interface/src/encode/encode_port.c index 0fb4018db1..eb464380c0 100644 --- a/lib/erl_interface/src/encode/encode_port.c +++ b/lib/erl_interface/src/encode/encode_port.c @@ -25,6 +25,7 @@ int ei_encode_port(char *buf, int *index, const erlang_port *p) { char *s = buf + *index; + const char tag = p->creation > 3 ? ERL_NEW_PORT_EXT : ERL_PORT_EXT; ++(*index); /* skip ERL_PORT_EXT */ if (ei_encode_atom_len_as(buf, index, p->node, strlen(p->node), ERLANG_UTF8, @@ -32,15 +33,19 @@ int ei_encode_port(char *buf, int *index, const erlang_port *p) return -1; } if (buf) { - put8(s, ERL_NEW_PORT_EXT); + put8(s, tag); s = buf + *index; /* now the integers */ put32be(s,p->id & 0x0fffffff /* 28 bits */); - put32be(s, p->creation); + if (tag == ERL_PORT_EXT) { + put8(s,(p->creation & 0x03)); + } else { + put32be(s, p->creation); + } } - *index += 4 + 4; + *index += 4 + (tag == ERL_PORT_EXT ? 1 : 4); return 0; } diff --git a/lib/erl_interface/src/encode/encode_ref.c b/lib/erl_interface/src/encode/encode_ref.c index 8c2e0a25f7..5ccfc32c6d 100644 --- a/lib/erl_interface/src/encode/encode_ref.c +++ b/lib/erl_interface/src/encode/encode_ref.c @@ -24,6 +24,7 @@ int ei_encode_ref(char *buf, int *index, const erlang_ref *p) { + const char tag = (p->creation > 3) ? ERL_NEWER_REFERENCE_EXT : ERL_NEW_REFERENCE_EXT; char *s = buf + *index; int i; @@ -36,7 +37,7 @@ int ei_encode_ref(char *buf, int *index, const erlang_ref *p) /* Always encode as an extended reference; all participating parties are now expected to be able to decode extended references. */ if (buf) { - put8(s, ERL_NEWER_REFERENCE_EXT); + put8(s, tag); /* first, number of integers */ put16be(s, p->len); @@ -45,12 +46,15 @@ int ei_encode_ref(char *buf, int *index, const erlang_ref *p) s = buf + *index; /* now the integers */ - put32be(s, p->creation); + if (tag == ERL_NEW_REFERENCE_EXT) + put8(s,(p->creation & 0x03)); + else + put32be(s, p->creation); for (i = 0; i < p->len; i++) put32be(s,p->n[i]); } - *index += p->len*4 + 4; + *index += p->len*4 + (tag == ERL_NEW_REFERENCE_EXT ? 1 : 4); return 0; } diff --git a/lib/erl_interface/src/epmd/ei_epmd.h b/lib/erl_interface/src/epmd/ei_epmd.h index f72c354e32..ac153b6e66 100644 --- a/lib/erl_interface/src/epmd/ei_epmd.h +++ b/lib/erl_interface/src/epmd/ei_epmd.h @@ -25,8 +25,8 @@ #endif #ifndef EI_DIST_HIGH -#define EI_DIST_HIGH 6 /* OTP 22 and later */ -#define EI_DIST_LOW 5 /* OTP R4 - 21 */ +#define EI_DIST_HIGH 5 /* R4 and later */ +#define EI_DIST_LOW 1 /* R3 and earlier */ #endif #ifndef EPMD_PORT @@ -45,7 +45,6 @@ #ifndef EI_EPMD_ALIVE2_REQ #define EI_EPMD_ALIVE2_REQ 120 #define EI_EPMD_ALIVE2_RESP 121 -#define EI_EPMD_ALIVE2_X_RESP 118 #define EI_EPMD_PORT2_REQ 122 #define EI_EPMD_PORT2_RESP 119 #define EI_EPMD_STOP_REQ 's' diff --git a/lib/erl_interface/src/epmd/epmd_publish.c b/lib/erl_interface/src/epmd/epmd_publish.c index ef8a5d6b70..20b8e867e8 100644 --- a/lib/erl_interface/src/epmd/epmd_publish.c +++ b/lib/erl_interface/src/epmd/epmd_publish.c @@ -68,8 +68,7 @@ static int ei_epmd_r4_publish (int port, const char *alive, unsigned ms) int nlen = strlen(alive); int len = elen + nlen + 13; /* hard coded: be careful! */ int n; - int err, response, res; - unsigned creation; + int err, res, creation; ssize_t dlen; unsigned tmo = ms == 0 ? EI_SCLBK_INF_TMO : ms; @@ -125,10 +124,8 @@ static int ei_epmd_r4_publish (int port, const char *alive, unsigned ms) /* Don't close fd here! It keeps us registered with epmd */ s = buf; - response = get8(s); - if (response != EI_EPMD_ALIVE2_RESP && - response != EI_EPMD_ALIVE2_X_RESP) { - EI_TRACE_ERR1("ei_epmd_r4_publish","<- unknown (%d)",response); + if (((res=get8(s)) != EI_EPMD_ALIVE2_RESP)) { /* response */ + EI_TRACE_ERR1("ei_epmd_r4_publish","<- unknown (%d)",res); EI_TRACE_ERR0("ei_epmd_r4_publish","-> CLOSE"); ei_close__(fd); erl_errno = EIO; @@ -144,21 +141,18 @@ static int ei_epmd_r4_publish (int port, const char *alive, unsigned ms) return -1; } - if (response == EI_EPMD_ALIVE2_RESP) - creation = get16be(s); - else /* EI_EPMD_ALIVE2_X_RESP */ - creation = get32be(s); + creation = get16be(s); EI_TRACE_CONN2("ei_epmd_r4_publish", - " result=%d (ok) creation=%u",res,creation); + " result=%d (ok) creation=%d",res,creation); - /* - * Would be nice to somehow use the nice "unique" creation value - * received here from epmd instead of using the crappy one - * passed (already) to ei_connect_init. - */ + /* probably should save fd so we can close it later... */ + /* epmd_saveconn(OPEN,fd,alive); */ - /* return the descriptor */ + /* return the creation number, for no good reason */ + /* return creation;*/ + + /* no - return the descriptor */ return fd; } diff --git a/lib/erl_interface/src/prog/erl_call.c b/lib/erl_interface/src/prog/erl_call.c index dce2ecdec2..ab91157035 100644 --- a/lib/erl_interface/src/prog/erl_call.c +++ b/lib/erl_interface/src/prog/erl_call.c @@ -292,7 +292,8 @@ int erl_call(int argc, char **argv) flags.cookie = NULL; } - creation = time(NULL) + 1; /* "random" */ + /* FIXME decide how many bits etc or leave to connect_xinit? */ + creation = (time(NULL) % 3) + 1; /* "random" */ if (flags.hidden == NULL) { /* As default we are c17@gethostname */ diff --git a/lib/erl_interface/test/erl_eterm_SUITE.erl b/lib/erl_interface/test/erl_eterm_SUITE.erl index 4605293c74..77910a9fc7 100644 --- a/lib/erl_interface/test/erl_eterm_SUITE.erl +++ b/lib/erl_interface/test/erl_eterm_SUITE.erl @@ -73,10 +73,6 @@ -import(runner, [get_term/1]). --define(REFERENCE_EXT, $e). --define(NEW_REFERENCE_EXT, $r). --define(NEWER_REFERENCE_EXT, $Z). - %% This test suite controls the running of the C language functions %% in eterm_test.c and print_term.c. @@ -1030,11 +1026,9 @@ cnode_1(Config) when is_list(Config) -> check_ref(Ref) -> case bin_ext_type(Ref) of - ?REFERENCE_EXT -> + 101 -> ct:fail(oldref); - ?NEW_REFERENCE_EXT -> - ok; - ?NEWER_REFERENCE_EXT -> + 114 -> ok; Type -> ct:fail({type, Type}) |