diff options
-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), |