aboutsummaryrefslogtreecommitdiffstats
path: root/erts/emulator/nifs/common/net_nif.c
diff options
context:
space:
mode:
authorMicael Karlberg <[email protected]>2018-07-13 12:34:06 +0200
committerMicael Karlberg <[email protected]>2018-09-18 14:50:18 +0200
commit416644989e26ac76038523511d81ebf9e0b8fc4f (patch)
treed730c1ba62de3789cbdd25d9c21aca09b23694f8 /erts/emulator/nifs/common/net_nif.c
parent3a2c48b2740f08d3582028fd2f8d626009aa911e (diff)
downloadotp-416644989e26ac76038523511d81ebf9e0b8fc4f.tar.gz
otp-416644989e26ac76038523511d81ebf9e0b8fc4f.tar.bz2
otp-416644989e26ac76038523511d81ebf9e0b8fc4f.zip
[net+socket-nif] Updated on_load stuff
The net nif-module had debug on by default. Fixed this and also made it an option, just as for the socket nif-module. OTP-14831
Diffstat (limited to 'erts/emulator/nifs/common/net_nif.c')
-rw-r--r--erts/emulator/nifs/common/net_nif.c20
1 files changed, 19 insertions, 1 deletions
diff --git a/erts/emulator/nifs/common/net_nif.c b/erts/emulator/nifs/common/net_nif.c
index 6829de509b..309ad05a36 100644
--- a/erts/emulator/nifs/common/net_nif.c
+++ b/erts/emulator/nifs/common/net_nif.c
@@ -209,6 +209,9 @@
# define SOCKLEN_T size_t
#endif
+/* Debug stuff... */
+#define NET_NIF_DEBUG_DEFAULT FALSE
+
#define NDBG( proto ) ESOCK_DBG_PRINTF( data.debug , proto )
@@ -331,6 +334,8 @@ static char* make_address_info(ErlNifEnv* env,
ERL_NIF_TERM addr,
ERL_NIF_TERM* ai);
+static BOOLEAN_T extract_debug(ErlNifEnv* env,
+ ERL_NIF_TERM map);
static int on_load(ErlNifEnv* env, void** priv_data, ERL_NIF_TERM load_info);
@@ -1535,6 +1540,19 @@ ErlNifFunc net_funcs[] =
};
+static
+BOOLEAN_T extract_debug(ErlNifEnv* env,
+ ERL_NIF_TERM map)
+{
+ /*
+ * We need to do this here since the "proper" atom has not been
+ * created when this function is called.
+ */
+ ERL_NIF_TERM debug = MKA(env, "debug");
+
+ return esock_extract_bool_from_map(env, map, debug, NET_NIF_DEBUG_DEFAULT);
+}
+
/* =======================================================================
* load_info - A map of misc info (e.g global debug)
@@ -1544,7 +1562,7 @@ static
int on_load(ErlNifEnv* env, void** priv_data, ERL_NIF_TERM load_info)
{
// We should make it possible to use load_info to get default values
- data.debug = TRUE;
+ data.debug = extract_debug(env, load_info);
NDBG( ("NET", "on_load -> entry\r\n") );