aboutsummaryrefslogtreecommitdiffstats
path: root/erts/emulator/nifs
diff options
context:
space:
mode:
authorMicael Karlberg <[email protected]>2019-03-18 12:42:47 +0100
committerMicael Karlberg <[email protected]>2019-03-18 12:42:47 +0100
commit47437fc6d9dd6a48a949dea3a33e66f40fa6431d (patch)
tree5551e1ada57dd72fd9bc4d6d4c3b94d4150de091 /erts/emulator/nifs
parent18cd707d9c3bdaffeb0d52ee596df383165225ce (diff)
downloadotp-47437fc6d9dd6a48a949dea3a33e66f40fa6431d.tar.gz
otp-47437fc6d9dd6a48a949dea3a33e66f40fa6431d.tar.bz2
otp-47437fc6d9dd6a48a949dea3a33e66f40fa6431d.zip
[socket] Fixed socket close issue
Fixed an issue (I think) that during socket close could cause a core.
Diffstat (limited to 'erts/emulator/nifs')
-rw-r--r--erts/emulator/nifs/common/socket_nif.c21
1 files changed, 11 insertions, 10 deletions
diff --git a/erts/emulator/nifs/common/socket_nif.c b/erts/emulator/nifs/common/socket_nif.c
index 174e97382e..654e5b6a9d 100644
--- a/erts/emulator/nifs/common/socket_nif.c
+++ b/erts/emulator/nifs/common/socket_nif.c
@@ -2408,7 +2408,8 @@ static void socket_down_reader(ErlNifEnv* env,
const ErlNifPid* pid);
static char* esock_send_close_msg(ErlNifEnv* env,
- SocketDescriptor* descP);
+ SocketDescriptor* descP,
+ ERL_NIF_TERM sockRef);
static char* esock_send_abort_msg(ErlNifEnv* env,
ERL_NIF_TERM sockRef,
ERL_NIF_TERM recvRef,
@@ -16894,15 +16895,15 @@ char* send_msg_error(ErlNifEnv* env,
*/
static
char* esock_send_close_msg(ErlNifEnv* env,
- SocketDescriptor* descP)
+ SocketDescriptor* descP,
+ ERL_NIF_TERM sockRef)
{
- ERL_NIF_TERM sockRef = enif_make_resource(descP->closeEnv, descP);
- char* res = esock_send_socket_msg(env,
- sockRef,
- esock_atom_close,
- descP->closeRef,
- &descP->closerPid,
- descP->closeEnv);
+ char* res = esock_send_socket_msg(env,
+ enif_make_copy(descP->closeEnv, sockRef),
+ esock_atom_close,
+ descP->closeRef,
+ &descP->closerPid,
+ descP->closeEnv);
descP->closeEnv = NULL;
@@ -17768,7 +17769,7 @@ void socket_stop(ErlNifEnv* env, void* obj, int fd, int is_direct_call)
/* +++ send close message to the waiting process +++ */
- esock_send_close_msg(env, descP);
+ esock_send_close_msg(env, descP, sockRef);
DEMONP("socket_stop -> closer", env, descP, &descP->closerMon);