aboutsummaryrefslogtreecommitdiffstats
path: root/erts/emulator/nifs
diff options
context:
space:
mode:
authorMicael Karlberg <[email protected]>2019-05-06 18:21:38 +0200
committerMicael Karlberg <[email protected]>2019-05-29 18:50:03 +0200
commit6ede678f9e7a2ba1b15c276e0e401d7990e88c51 (patch)
tree903e90d2a8eeb94e4af1af0532f50ac5e632bcc5 /erts/emulator/nifs
parentd6dddf8ec963d34c91ec92b4772ff34238f2c718 (diff)
downloadotp-6ede678f9e7a2ba1b15c276e0e401d7990e88c51.tar.gz
otp-6ede678f9e7a2ba1b15c276e0e401d7990e88c51.tar.bz2
otp-6ede678f9e7a2ba1b15c276e0e401d7990e88c51.zip
[esock] Types and cleanup
Changed tag type tpo opaque. Also added connect (monitor and process) cleanup. OTP-15731
Diffstat (limited to 'erts/emulator/nifs')
-rw-r--r--erts/emulator/nifs/common/socket_nif.c17
1 files changed, 15 insertions, 2 deletions
diff --git a/erts/emulator/nifs/common/socket_nif.c b/erts/emulator/nifs/common/socket_nif.c
index 1a8ce89b7b..4394e7bc7c 100644
--- a/erts/emulator/nifs/common/socket_nif.c
+++ b/erts/emulator/nifs/common/socket_nif.c
@@ -4966,7 +4966,7 @@ ERL_NIF_TERM nconnect(ErlNifEnv* env,
descP->state = SOCKET_STATE_CONNECTED;
enif_set_pid_undefined(&descP->connPid);
- MON_INIT(&descP->connMon);
+ DEMONP("nconnect -> connected", env, descP, &descP->connMon);
descP->isReadable = TRUE;
descP->isWritable = TRUE;
@@ -5026,7 +5026,7 @@ ERL_NIF_TERM nfinalize_connection(ErlNifEnv* env,
{
int error;
- if (descP->state != SOCKET_STATE_CONNECTING)
+ if (!IS_CONNECTING(descP))
return esock_make_error(env, atom_enotconn);
if (!verify_is_connected(descP, &error)) {
@@ -5035,6 +5035,8 @@ ERL_NIF_TERM nfinalize_connection(ErlNifEnv* env,
}
descP->state = SOCKET_STATE_CONNECTED;
+ enif_set_pid_undefined(&descP->connPid);
+ DEMONP("nfinalize_connection -> connected", env, descP, &descP->connMon);
descP->isReadable = TRUE;
descP->isWritable = TRUE;
@@ -18705,6 +18707,17 @@ void socket_down(ErlNifEnv* env,
MON2T(env, mon));
}
+ } else if (COMPARE_PIDS(&descP->connPid, pid) == 0) {
+
+ /* The connPid is only set during the connection.
+ * The same goes for the monitor (connMon).
+ */
+
+ descP->state = SOCKET_STATE_OPEN; /* restore state */
+ enif_set_pid_undefined(&descP->connPid);
+ DEMONP("socket_down -> connector",
+ env, descP, &descP->connMon);
+
} else {
/* check all operation queue(s): acceptor, writer and reader.