Skip to content

Commit ab2e4c3

Browse files
committed
ae.net.asockets: Fix EPOLLHUP handling
Handle it as a read event instead of an error.
1 parent f1b127b commit ab2e4c3

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

net/asockets.d

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -252,8 +252,8 @@ static if (eventLoopMechanism == EventLoopMechanism.epoll)
252252
assert(conn !is null, "epoll event with null socket");
253253

254254
runUserEventHandler({
255-
// Handle errors first
256-
if (ev.events & (EPOLLERR | EPOLLHUP))
255+
// Handle errors
256+
if (ev.events & EPOLLERR)
257257
{
258258
debug (ASOCKETS) stderr.writefln("\t%s - error", conn);
259259
string errMsg = "socket error";
@@ -273,8 +273,8 @@ static if (eventLoopMechanism == EventLoopMechanism.epoll)
273273
debug (ASOCKETS) stderr.writefln("\t%s - calling onWritable", conn);
274274
conn.onWritable();
275275
}
276-
// Then read
277-
else if (ev.events & EPOLLIN)
276+
// Then read (EPOLLHUP also triggers read so recv() returns 0 for EOF)
277+
else if (ev.events & (EPOLLIN | EPOLLHUP))
278278
{
279279
debug (ASOCKETS) stderr.writefln("\t%s - calling onReadable", conn);
280280
conn.onReadable();

0 commit comments

Comments
 (0)