Skip to content

Commit e8d1304

Browse files
committed
event/EpollEvents: add ANY_HANGUP
Portable abstraction that allows matching both EPOLLHUP and the Linux-specific EPOLLRDHUP.
1 parent b19a0fb commit e8d1304

3 files changed

Lines changed: 21 additions & 3 deletions

File tree

src/event/EpollEvents.hxx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,16 @@ struct EpollEvents {
1212
static constexpr unsigned HANGUP = EPOLLHUP;
1313
static constexpr unsigned READ_HANGUP = EPOLLRDHUP;
1414

15+
/**
16+
* Any kind of hangup, i.e. the normal EPOLLHUP plus the
17+
* Linux-specific EPOLLRDHUP.
18+
*/
19+
static constexpr unsigned ANY_HANGUP = HANGUP|READ_HANGUP;
20+
1521
/**
1622
* A mask containing all events which indicate a dead socket
1723
* connection (i.e. error or hangup). It may still be
1824
* possible to receive pending data from the socket buffer.
1925
*/
20-
static constexpr unsigned DEAD_MASK = ERROR|HANGUP|READ_HANGUP;
26+
static constexpr unsigned DEAD_MASK = ERROR|ANY_HANGUP;
2127
};

src/event/PollEvents.hxx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,16 @@ struct PollEvents {
1010
static constexpr unsigned ERROR = POLLERR;
1111
static constexpr unsigned HANGUP = POLLHUP;
1212

13+
/**
14+
* Any kind of hangup, i.e. the normal EPOLLHUP plus the
15+
* Linux-specific EPOLLRDHUP.
16+
*/
17+
static constexpr unsigned ANY_HANGUP = HANGUP;
18+
1319
/**
1420
* A mask containing all events which indicate a dead socket
1521
* connection (i.e. error or hangup). It may still be
1622
* possible to receive pending data from the socket buffer.
1723
*/
18-
static constexpr unsigned DEAD_MASK = ERROR|HANGUP;
24+
static constexpr unsigned DEAD_MASK = ERROR|ANY_HANGUP;
1925
};

src/event/WinSelectEvents.hxx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,16 @@ struct WinSelectEvents {
1616
static constexpr unsigned ERROR = 0;
1717
static constexpr unsigned HANGUP = 0;
1818

19+
/**
20+
* Any kind of hangup, i.e. the normal EPOLLHUP plus the
21+
* Linux-specific EPOLLRDHUP.
22+
*/
23+
static constexpr unsigned ANY_HANGUP = HANGUP;
24+
1925
/**
2026
* A mask containing all events which indicate a dead socket
2127
* connection (i.e. error or hangup). It may still be
2228
* possible to receive pending data from the socket buffer.
2329
*/
24-
static constexpr unsigned DEAD_MASK = ERROR|HANGUP;
30+
static constexpr unsigned DEAD_MASK = ERROR|ANY_HANGUP;
2531
};

0 commit comments

Comments
 (0)