diff options
author | Sverker Eriksson <sverker@erlang.org> | 2020-04-01 09:53:49 +0000 |
---|---|---|
committer | Sverker Eriksson <sverker@erlang.org> | 2020-04-02 19:43:33 +0200 |
commit | 02378c6fb46b31e92c69ffe86e4dc3d74accb7b7 (patch) | |
tree | 3a1b07ffb33737aae95845f7412cad41eed1b1a9 /erts | |
parent | c3ad753819ebf5c6e1aed058a609239c4ab0d8d5 (diff) | |
download | erlang-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.c | 4 |
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) { |