File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -10,11 +10,12 @@ struct EpollEvents {
1010 static constexpr unsigned WRITE = EPOLLOUT ;
1111 static constexpr unsigned ERROR = EPOLLERR ;
1212 static constexpr unsigned HANGUP = EPOLLHUP ;
13+ static constexpr unsigned READ_HANGUP = EPOLLRDHUP ;
1314
1415 /* *
1516 * A mask containing all events which indicate a dead socket
1617 * connection (i.e. error or hangup). It may still be
1718 * possible to receive pending data from the socket buffer.
1819 */
19- static constexpr unsigned DEAD_MASK = ERROR |HANGUP ;
20+ static constexpr unsigned DEAD_MASK = ERROR |HANGUP | READ_HANGUP ;
2021};
Original file line number Diff line number Diff line change 44#pragma once
55
66#include " BackendEvents.hxx"
7+ #include " event/Features.h" // for USE_EPOLL
78#include " net/SocketDescriptor.hxx"
89#include " util/BindMethod.hxx"
910#include " util/IntrusiveList.hxx"
@@ -175,6 +176,18 @@ public:
175176 Schedule (IMPLICIT_FLAGS );
176177 }
177178
179+ #ifdef USE_EPOLL
180+ /* *
181+ * Cancel READ but schedule READ_HANGUP. This is useful to be
182+ * able to detect hangup while we're not interested in reading
183+ * further data from the socket; in that case, the Linux
184+ * kernel will not report HANGUP.
185+ */
186+ void CancelReadAndScheduleReadHangup () noexcept {
187+ Schedule ((GetScheduledFlags () & ~READ ) | READ_HANGUP );
188+ }
189+ #endif
190+
178191 bool IsReadPending () const noexcept {
179192 return GetScheduledFlags () & READ ;
180193 }
You can’t perform that action at this time.
0 commit comments