diff options
author | Sverker Eriksson <[email protected]> | 2019-02-06 16:29:34 +0100 |
---|---|---|
committer | Micael Karlberg <[email protected]> | 2019-02-22 19:45:52 +0100 |
commit | b278a8bba833a681d692fc95f3c77c57f2d0ac69 (patch) | |
tree | bc8896afa5509ade09e7ecd0fed2278a5c579608 | |
parent | a217c7185727cd69da5f780ac63b68b46bc1d9b4 (diff) | |
download | otp-b278a8bba833a681d692fc95f3c77c57f2d0ac69.tar.gz otp-b278a8bba833a681d692fc95f3c77c57f2d0ac69.tar.bz2 otp-b278a8bba833a681d692fc95f3c77c57f2d0ac69.zip |
[socket-nif] Fix currentReader/Writer always set at enif_select
-rw-r--r-- | erts/emulator/nifs/common/socket_nif.c | 25 |
1 files changed, 14 insertions, 11 deletions
diff --git a/erts/emulator/nifs/common/socket_nif.c b/erts/emulator/nifs/common/socket_nif.c index 843fe2440f..f97e5b6867 100644 --- a/erts/emulator/nifs/common/socket_nif.c +++ b/erts/emulator/nifs/common/socket_nif.c @@ -13584,14 +13584,14 @@ ERL_NIF_TERM send_check_result(ErlNifEnv* env, /* Ok, try again later */ SSDBG( descP, ("SOCKET", "send_check_result -> try again\r\n") ); - - SELECT(env, descP->sock, (ERL_NIF_SELECT_WRITE), descP, NULL, sendRef); - - return esock_make_error(env, esock_atom_eagain); - } } + else { + SSDBG( descP, + ("SOCKET", "send_check_result -> " + "not entire package written (%d of %d)\r\n", written, dataSize) ); + } /* We failed to write the *entire* packet (anything less then size * of the packet, which is 0 <= written < sizeof packet), @@ -13617,12 +13617,10 @@ ERL_NIF_TERM send_check_result(ErlNifEnv* env, SELECT(env, descP->sock, (ERL_NIF_SELECT_WRITE), descP, NULL, sendRef); - SSDBG( descP, - ("SOCKET", "send_check_result -> " - "not entire package written (%d of %d)\r\n", written, dataSize) ); - - return esock_make_ok2(env, MKI(env, written)); - + if (written >= 0) + return esock_make_ok2(env, MKI(env, written)); + else + return esock_make_error(env, esock_atom_eagain); } @@ -14096,6 +14094,11 @@ ERL_NIF_TERM recv_check_result(ErlNifEnv* env, SSDBG( descP, ("SOCKET", "recv_check_result -> [%d] " "only part of message - expect more\r\n", toRead) ); + if ((xres = recv_init_current_reader(env, descP, recvRef)) != NULL) { + FREE_BIN(bufP); + return esock_make_error_str(env, xres); + } + /* SELECT for more data */ SELECT(env, descP->sock, (ERL_NIF_SELECT_READ), |