Skip to content

Commit 571eab1

Browse files
committed
Report a socket writable after SHUT_WR so a blocked writer wakes and fails
1 parent 3d82dc1 commit 571eab1

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

‎src/sockets.ts‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,8 @@ export class Sock {
166166
if (this.connecting) return r;
167167
if (!this.connected) return r | POLLOUT | POLLHUP;
168168
if (this.rxBytes > 0 || this.eof || (this.shutRd && !this.pipe)) r |= POLLIN;
169-
if (!this.shutWr && !this.wblocked) r |= POLLOUT;
169+
// after SHUT_WR a write fails at once, so Linux reports the socket writable
170+
if (this.shutWr ? !this.pipe : !this.wblocked) r |= POLLOUT;
170171
if (this.pipe && this.shutRd && !this.peer) r |= POLLERR;
171172
if ((this.eof || this.shutRd) && this.shutWr) r |= POLLHUP;
172173
return r;

0 commit comments

Comments
 (0)