File tree Expand file tree Collapse file tree 3 files changed +36
-0
lines changed Expand file tree Collapse file tree 3 files changed +36
-0
lines changed Original file line number Diff line number Diff line change @@ -61,6 +61,29 @@ cdef class UVPoll(UVHandle):
61
61
self ._fatal_error(exc, True )
62
62
return
63
63
64
+ IF UNAME_SYSNAME == " Linux" :
65
+ # libuv doesn't remove the FD from epoll immediately
66
+ # after uv_poll_stop or uv_poll_close, causing hard
67
+ # to debug issue with dup-ed file descriptors causing
68
+ # CPU burn in epoll/epoll_ctl:
69
+ # https://github.com/MagicStack/uvloop/issues/61
70
+ #
71
+ # It's safe though to manually call epoll_ctl here,
72
+ # after calling uv_poll_stop.
73
+
74
+ cdef:
75
+ int backend_id
76
+ system.epoll_event dummy_event
77
+
78
+ backend_id = uv.uv_backend_fd(self ._loop.uvloop)
79
+ if backend_id != - 1 :
80
+ memset(& dummy_event, 0 , sizeof(dummy_event))
81
+ system.epoll_ctl(
82
+ backend_id,
83
+ system.EPOLL_CTL_DEL,
84
+ self .fd,
85
+ & dummy_event) # ignore errors
86
+
64
87
cdef start_reading(self , Handle callback):
65
88
cdef:
66
89
int mask = 0
Original file line number Diff line number Diff line change @@ -63,3 +63,15 @@ cdef extern from "includes/compat.h" nogil:
63
63
64
64
cdef int EWOULDBLOCK
65
65
cdef int PLATFORM_IS_APPLE
66
+
67
+
68
+ IF UNAME_SYSNAME == " Linux" :
69
+
70
+ cdef extern from " sys/epoll.h" nogil:
71
+
72
+ struct epoll_event:
73
+ # We don't use the fields
74
+ pass
75
+
76
+ int EPOLL_CTL_DEL
77
+ int epoll_ctl(int epfd, int op, int fd, epoll_event * event)
Original file line number Diff line number Diff line change @@ -266,6 +266,7 @@ cdef extern from "uv.h" nogil:
266
266
int uv_loop_init(uv_loop_t* loop)
267
267
int uv_loop_close(uv_loop_t* loop)
268
268
int uv_loop_alive(uv_loop_t* loop)
269
+ int uv_backend_fd(uv_loop_t* loop)
269
270
270
271
void uv_update_time(uv_loop_t* loop)
271
272
uint64_t uv_now(const uv_loop_t* )
You can’t perform that action at this time.
0 commit comments