diff options
author | Alon Zakai <alonzakai@gmail.com> | 2013-03-25 18:03:02 -0700 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2013-03-25 18:03:02 -0700 |
commit | 926a1f21a06442dbcabfce97fef2257641b5c13c (patch) | |
tree | f257237389f7052518dfb6229058a43eac2d716d /src/library.js | |
parent | 5cedd415bd1b379f96af4e2487b75fecc407759a (diff) | |
parent | 1fecc4b3072c6a0cfef5c629f50cbaa647ea98b1 (diff) |
Merge pull request #898 from MichaelRiss/selectFix
select function: return error condition when network connection fails
Diffstat (limited to 'src/library.js')
-rw-r--r-- | src/library.js | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/src/library.js b/src/library.js index 166a015f..b63ac955 100644 --- a/src/library.js +++ b/src/library.js @@ -7297,11 +7297,17 @@ LibraryManager.library = { // exceptfds not supported // timeout is always 0 - fully async assert(!exceptfds); + + var errorCondition = 0; function canRead(info) { // make sure hasData exists. // we do create it when the socket is connected, // but other implementations may create it lazily + if ((info.socket.readyState == WebSocket.CLOSING || info.socket.readyState == WebSocket.CLOSED) && info.inQueue.length == 0) { + errorCondition = -1; + return false; + } return info.hasData && info.hasData(); } @@ -7309,6 +7315,10 @@ LibraryManager.library = { // make sure socket exists. // we do create it when the socket is connected, // but other implementations may create it lazily + if ((info.socket.readyState == WebSocket.CLOSING || info.socket.readyState == WebSocket.CLOSED)) { + errorCondition = -1; + return false; + } return info.socket && (info.socket.readyState == info.socket.OPEN); } @@ -7340,8 +7350,13 @@ LibraryManager.library = { return bitsSet; } - return checkfds(nfds, readfds, canRead) - + checkfds(nfds, writefds, canWrite); + var totalHandles = checkfds(nfds, readfds, canRead) + checkfds(nfds, writefds, canWrite); + if (errorCondition) { + ___setErrNo(ERRNO_CODES.EBADF); + return -1; + } else { + return totalHandles; + } }, // pty.h |