aboutsummaryrefslogtreecommitdiffstats
path: root/erts/emulator/nifs/common
diff options
context:
space:
mode:
authorMicael Karlberg <[email protected]>2018-10-22 14:19:29 +0200
committerMicael Karlberg <[email protected]>2018-10-22 14:19:29 +0200
commitada0029d11c33cef2b2aabc9ef2902a98f574ffb (patch)
treedd0427469e1307bead7de89a665ed7b4d249d852 /erts/emulator/nifs/common
parent76d0b4f3814273ee92efd2d4aaeac12c6f655f05 (diff)
downloadotp-ada0029d11c33cef2b2aabc9ef2902a98f574ffb.tar.gz
otp-ada0029d11c33cef2b2aabc9ef2902a98f574ffb.tar.bz2
otp-ada0029d11c33cef2b2aabc9ef2902a98f574ffb.zip
[socket-nif] Initiation of "current reader" missing for recvfrom
When calling the recvfrom function when there is no data, we should be made wait (for the specified amount of time). But this did not work because the "current reader" structure was not initiated. OTP-14831
Diffstat (limited to 'erts/emulator/nifs/common')
-rw-r--r--erts/emulator/nifs/common/socket_nif.c17
1 files changed, 12 insertions, 5 deletions
diff --git a/erts/emulator/nifs/common/socket_nif.c b/erts/emulator/nifs/common/socket_nif.c
index 45462ff772..f9eb041ad1 100644
--- a/erts/emulator/nifs/common/socket_nif.c
+++ b/erts/emulator/nifs/common/socket_nif.c
@@ -13377,21 +13377,24 @@ BOOLEAN_T recv_check_reader(ErlNifEnv* env,
}
if (!compare_pids(env, &descP->currentReader.pid, &caller)) {
+ ERL_NIF_TERM tmp;
+
/* Not the "current reader", so (maybe) push onto queue */
SSDBG( descP,
("SOCKET", "recv_check_reader -> not (current) reader\r\n") );
if (!reader_search4pid(env, descP, &caller))
- *checkResult = reader_push(env, descP, caller, ref);
+ tmp = reader_push(env, descP, caller, ref);
else
- *checkResult = esock_make_error(env, esock_atom_eagain);
+ tmp = esock_make_error(env, esock_atom_eagain);
SSDBG( descP,
("SOCKET",
- "recv_check_reader -> queue (push) result: %T\r\n",
- checkResult) );
-
+ "recv_check_reader -> queue (push) result: %T\r\n", tmp) );
+
+ *checkResult = tmp;
+
return FALSE;
}
@@ -13769,6 +13772,7 @@ ERL_NIF_TERM recvfrom_check_result(ErlNifEnv* env,
unsigned int fromAddrLen,
ERL_NIF_TERM recvRef)
{
+ char* xres;
ERL_NIF_TERM data;
SSDBG( descP,
@@ -13818,6 +13822,9 @@ ERL_NIF_TERM recvfrom_check_result(ErlNifEnv* env,
SSDBG( descP, ("SOCKET", "recvfrom_check_result -> eagain\r\n") );
+ if ((xres = recv_init_current_reader(env, descP, recvRef)) != NULL)
+ return esock_make_error_str(env, xres);
+
SELECT(env, descP->sock, (ERL_NIF_SELECT_READ),
descP, NULL, recvRef);