From 337919abe6ed9a97e15d5f471ef8f79d44cb8363 Mon Sep 17 00:00:00 2001 From: Sverker Eriksson Date: Mon, 26 Feb 2018 15:36:34 +0100 Subject: erts,kernel: Add erts_internal:get_dflags/0 for kernel to ask erts about distribution flags and keep this info in one place. --- erts/emulator/beam/dist.h | 37 +++++++++++++++++++++++++++++++------ 1 file changed, 31 insertions(+), 6 deletions(-) (limited to 'erts/emulator/beam/dist.h') diff --git a/erts/emulator/beam/dist.h b/erts/emulator/beam/dist.h index ea4697815f..202457bb3b 100644 --- a/erts/emulator/beam/dist.h +++ b/erts/emulator/beam/dist.h @@ -40,26 +40,51 @@ #define DFLAG_UNICODE_IO 0x1000 #define DFLAG_DIST_HDR_ATOM_CACHE 0x2000 #define DFLAG_SMALL_ATOM_TAGS 0x4000 -#define DFLAG_INTERNAL_TAGS 0x8000 +#define DFLAG_INTERNAL_TAGS 0x8000 /* used by ETS 'compressed' option */ #define DFLAG_UTF8_ATOMS 0x10000 #define DFLAG_MAP_TAG 0x20000 #define DFLAG_BIG_CREATION 0x40000 #define DFLAG_SEND_SENDER 0x80000 -#define DFLAG_NO_MAGIC 0x100000 +#define DFLAG_NO_MAGIC 0x100000 /* internal for pending connection */ -/* Mandatory flags for distribution (sync with dist_util.erl) */ +/* Mandatory flags for distribution */ #define DFLAG_DIST_MANDATORY (DFLAG_EXTENDED_REFERENCES \ | DFLAG_EXTENDED_PIDS_PORTS \ | DFLAG_UTF8_ATOMS \ | DFLAG_NEW_FUN_TAGS) -/* Additional optimistic flags when encoding toward pending connection */ -#define DFLAG_DIST_HOPEFULLY (DFLAG_NO_MAGIC \ - | DFLAG_EXPORT_PTR_TAG \ +/* + * Additional optimistic flags when encoding toward pending connection. + * If remote node does not supporting these (erl_interface) + * then we will need to transcode all messages enqueued before + * connection setup was finished. + */ +#define DFLAG_DIST_HOPEFULLY (DFLAG_EXPORT_PTR_TAG \ | DFLAG_BIT_BINARIES \ | DFLAG_DIST_MONITOR \ | DFLAG_DIST_MONITOR_NAME) +/* Our preferred set of flags. Used for connection setup handshake */ +#define DFLAG_DIST_DEFAULT (DFLAG_DIST_MANDATORY | DFLAG_DIST_HOPEFULLY \ + | DFLAG_FUN_TAGS \ + | DFLAG_NEW_FLOATS \ + | DFLAG_UNICODE_IO \ + | DFLAG_DIST_HDR_ATOM_CACHE \ + | DFLAG_SMALL_ATOM_TAGS \ + | DFLAG_UTF8_ATOMS \ + | DFLAG_MAP_TAG \ + | DFLAG_BIG_CREATION \ + | DFLAG_SEND_SENDER) + +/* Flags addable by local distr implementations */ +#define DFLAG_DIST_ADDABLE DFLAG_DIST_DEFAULT + +/* Flags rejectable by local distr implementation */ +#define DFLAG_DIST_REJECTABLE (DFLAG_DIST_HDR_ATOM_CACHE \ + | DFLAG_HIDDEN_ATOM_CACHE \ + | DFLAG_ATOM_CACHE) + + /* All flags that should be enabled when term_to_binary/1 is used. */ #define TERM_TO_BINARY_DFLAGS (DFLAG_EXTENDED_REFERENCES \ | DFLAG_NEW_FUN_TAGS \ -- cgit v1.2.3 From 7fb3ed7d2731050186eb5224fe8e6050e4909341 Mon Sep 17 00:00:00 2001 From: Sverker Eriksson Date: Mon, 26 Feb 2018 20:40:51 +0100 Subject: erts,kernel: Add dist_util:strict_order_flags/0 to replace DFLAGS_STRICT_ORDER_DELIVERY and remove that compile time dependency. --- erts/emulator/beam/dist.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'erts/emulator/beam/dist.h') diff --git a/erts/emulator/beam/dist.h b/erts/emulator/beam/dist.h index 202457bb3b..e8dcdb669d 100644 --- a/erts/emulator/beam/dist.h +++ b/erts/emulator/beam/dist.h @@ -84,6 +84,8 @@ | DFLAG_HIDDEN_ATOM_CACHE \ | DFLAG_ATOM_CACHE) +/* Flags for all features needing strict order delivery */ +#define DFLAG_DIST_STRICT_ORDER DFLAG_DIST_HDR_ATOM_CACHE /* All flags that should be enabled when term_to_binary/1 is used. */ #define TERM_TO_BINARY_DFLAGS (DFLAG_EXTENDED_REFERENCES \ -- cgit v1.2.3 From c10e3e1fc83cbccd1c8c3b377e2309ea8fa27572 Mon Sep 17 00:00:00 2001 From: Sverker Eriksson Date: Thu, 1 Mar 2018 12:27:48 +0100 Subject: erts: Optimize dist transcoding toward erl_/jinterface to only transcode if output buffer actually contains unsupported BIT_BINARY_EXT or EXPORT_EXT. --- erts/emulator/beam/dist.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'erts/emulator/beam/dist.h') diff --git a/erts/emulator/beam/dist.h b/erts/emulator/beam/dist.h index e8dcdb669d..000c66a00f 100644 --- a/erts/emulator/beam/dist.h +++ b/erts/emulator/beam/dist.h @@ -55,9 +55,8 @@ /* * Additional optimistic flags when encoding toward pending connection. - * If remote node does not supporting these (erl_interface) - * then we will need to transcode all messages enqueued before - * connection setup was finished. + * If remote node (erl_interface) does not supporting these then we may need + * to transcode messages enqueued before connection setup was finished. */ #define DFLAG_DIST_HOPEFULLY (DFLAG_EXPORT_PTR_TAG \ | DFLAG_BIT_BINARIES \ @@ -355,6 +354,7 @@ typedef struct TTBSizeContext_ { typedef struct TTBEncodeContext_ { Uint flags; + Uint hopefull_flags; int level; byte* ep; Eterm obj; -- cgit v1.2.3 From b31750711daa35011c62898d2eb424332e170bcc Mon Sep 17 00:00:00 2001 From: Sverker Eriksson Date: Thu, 1 Mar 2018 16:36:17 +0100 Subject: erts: Refactor DistEntry.status flags into a state Just to simplify and get 4 distinctive states IDLE, PENDING, CONNECTED and EXITING. The old possible flag combos were: 0 PENDING CONNECTED CONNECTED|EXITING EXITING The two EXITING states did not serve any purpose other then as a slight optimization in monitor_node(_,false,_) to shortcut EXITING when there can be no monitors. --- erts/emulator/beam/dist.h | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) (limited to 'erts/emulator/beam/dist.h') diff --git a/erts/emulator/beam/dist.h b/erts/emulator/beam/dist.h index 000c66a00f..b1b7ce9c78 100644 --- a/erts/emulator/beam/dist.h +++ b/erts/emulator/beam/dist.h @@ -137,14 +137,6 @@ typedef struct { int no_suspend; } ErtsDSigData; -#define ERTS_DE_IS_NOT_CONNECTED(DEP) \ - (ERTS_LC_ASSERT(erts_lc_rwmtx_is_rlocked(&(DEP)->rwmtx) \ - || erts_lc_rwmtx_is_rwlocked(&(DEP)->rwmtx)), \ - (is_nil((DEP)->cid) || ((DEP)->status & ERTS_DE_SFLG_EXITING))) - -#define ERTS_DE_IS_CONNECTED(DEP) \ - (!ERTS_DE_IS_NOT_CONNECTED((DEP))) - #define ERTS_DE_BUSY_LIMIT (1024*1024) extern int erts_dist_buf_busy_limit; extern int erts_is_alive; @@ -207,18 +199,18 @@ erts_dsig_prepare(ErtsDSigData *dsdp, retry: erts_de_rlock(dep); - if (ERTS_DE_IS_CONNECTED(dep)) { + if (dep->state == ERTS_DE_STATE_CONNECTED) { res = ERTS_DSIG_PREP_CONNECTED; } - else if (dep->status & ERTS_DE_SFLG_PENDING) { + else if (dep->state == ERTS_DE_STATE_PENDING) { res = ERTS_DSIG_PREP_PENDING; } - else if (dep->status & ERTS_DE_SFLG_EXITING) { + else if (dep->state == ERTS_DE_STATE_EXITING) { res = ERTS_DSIG_PREP_NOT_CONNECTED; goto fail; } else if (connect) { - ASSERT(dep->status == 0); + ASSERT(dep->state == ERTS_DE_STATE_IDLE); erts_de_runlock(dep); if (!erts_auto_connect(dep, proc, proc_locks)) { return ERTS_DSIG_PREP_NOT_ALIVE; @@ -226,7 +218,7 @@ retry: goto retry; } else { - ASSERT(dep->status == 0); + ASSERT(dep->state == ERTS_DE_STATE_IDLE); res = ERTS_DSIG_PREP_NOT_CONNECTED; goto fail; } -- cgit v1.2.3