summaryrefslogtreecommitdiff
path: root/erts
diff options
context:
space:
mode:
authorSverker Eriksson <sverker@erlang.org>2020-04-01 09:53:49 +0000
committerSverker Eriksson <sverker@erlang.org>2020-04-02 19:43:33 +0200
commit02378c6fb46b31e92c69ffe86e4dc3d74accb7b7 (patch)
tree3a1b07ffb33737aae95845f7412cad41eed1b1a9 /erts
parentc3ad753819ebf5c6e1aed058a609239c4ab0d8d5 (diff)
downloaderlang-02378c6fb46b31e92c69ffe86e4dc3d74accb7b7.tar.gz
erts: Fix windows spin bug when stdio is closed
Example symptom: os:cmd("escript something") would cause 100% cpu and even increasing memory consumption. Problem: threaded_reader() keeps calling ReadFile and getting 0 bytes read which are even sent as {Port, {data, <<>>}} messages from port. Fix: Exit threaded_reader() if 0 bytes is read. This was already done but only if CRLF->LF conversion was disabled, which I don't understand why. Could be someone was "unlucky" thinking "the CRLF conversion may decrease bytesTransferred down to zero", which it cannot.
Diffstat (limited to 'erts')
-rw-r--r--erts/emulator/sys/win32/sys.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/erts/emulator/sys/win32/sys.c b/erts/emulator/sys/win32/sys.c
index 957ade51c3..64d61b4d19 100644
--- a/erts/emulator/sys/win32/sys.c
+++ b/erts/emulator/sys/win32/sys.c
@@ -1697,7 +1697,7 @@ create_child_process
erts_free(ERTS_ALC_T_TMP, qte);
}
- DEBUGF((stderr,"Creating child process: %S, createFlags = %d\n", newcmdline, createFlags));
+ DEBUGF(("Creating child process: %S, createFlags = %d\n", newcmdline, createFlags));
ok = CreateProcessW((wchar_t *) appname,
(wchar_t *) newcmdline,
NULL,
@@ -1995,7 +1995,7 @@ threaded_reader(LPVOID param)
aio->bytesTransferred = n;
}
SetEvent(aio->ov.hEvent);
- if ((aio->flags & DF_XLAT_CR) == 0 && aio->bytesTransferred == 0) {
+ if (aio->bytesTransferred == 0) {
break;
}
if (aio->pendingError != NO_ERROR) {