Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gevent
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
gevent
Commits
a5f7a836
Commit
a5f7a836
authored
Feb 20, 2018
by
Jason Madden
Committed by
GitHub
Feb 20, 2018
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1111 from gevent/libev-cffi-cleanup
Cleanup the libev destroyed data like the libuv destroyed data.
parents
b3eebab9
92d77791
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
74 additions
and
60 deletions
+74
-60
src/gevent/_ffi/loop.py
src/gevent/_ffi/loop.py
+5
-8
src/gevent/libev/_corecffi_cdef.c
src/gevent/libev/_corecffi_cdef.c
+4
-0
src/gevent/libev/_corecffi_source.c
src/gevent/libev/_corecffi_source.c
+15
-0
src/gevent/libev/corecffi.py
src/gevent/libev/corecffi.py
+14
-6
src/gevent/libuv/loop.py
src/gevent/libuv/loop.py
+36
-46
No files found.
src/gevent/_ffi/loop.py
View file @
a5f7a836
...
@@ -295,8 +295,6 @@ else:
...
@@ -295,8 +295,6 @@ else:
_default_loop_destroyed
=
False
_NOARGS
=
()
_NOARGS
=
()
...
@@ -320,9 +318,6 @@ class AbstractLoop(object):
...
@@ -320,9 +318,6 @@ class AbstractLoop(object):
# whether they were the default loop.
# whether they were the default loop.
_default
=
None
_default
=
None
# A class variable.
_default_loop_destroyed
=
False
def
__init__
(
self
,
ffi
,
lib
,
watchers
,
flags
=
None
,
default
=
None
):
def
__init__
(
self
,
ffi
,
lib
,
watchers
,
flags
=
None
,
default
=
None
):
self
.
_ffi
=
ffi
self
.
_ffi
=
ffi
self
.
_lib
=
lib
self
.
_lib
=
lib
...
@@ -493,21 +488,23 @@ class AbstractLoop(object):
...
@@ -493,21 +488,23 @@ class AbstractLoop(object):
try
:
try
:
if
not
self
.
_can_destroy_loop
(
self
.
_ptr
):
if
not
self
.
_can_destroy_loop
(
self
.
_ptr
):
return
False
return
False
self
.
_destroyed_loop
(
self
.
_ptr
)
self
.
_stop_aux_watchers
()
self
.
_stop_aux_watchers
()
self
.
_destroy_loop
(
self
.
_ptr
)
finally
:
finally
:
# not ffi.NULL, we don't want something that can be
# not ffi.NULL, we don't want something that can be
# passed to C and crash later. This will create nice friendly
# passed to C and crash later. This will create nice friendly
# TypeError from CFFI.
# TypeError from CFFI.
self
.
_ptr
=
None
self
.
_ptr
=
None
del
self
.
_handle_to_self
del
self
.
_callbacks
del
self
.
_keepaliveset
return
True
return
True
def
_can_destroy_loop
(
self
,
ptr
):
def
_can_destroy_loop
(
self
,
ptr
):
raise
NotImplementedError
()
raise
NotImplementedError
()
def
_destroy
ed
_loop
(
self
,
ptr
):
def
_destroy_loop
(
self
,
ptr
):
raise
NotImplementedError
()
raise
NotImplementedError
()
@
property
@
property
...
...
src/gevent/libev/_corecffi_cdef.c
View file @
a5f7a836
...
@@ -237,3 +237,7 @@ extern "Python" {
...
@@ -237,3 +237,7 @@ extern "Python" {
* object.
* object.
*/
*/
static
void
_gevent_generic_callback
(
struct
ev_loop
*
loop
,
struct
ev_watcher
*
watcher
,
int
revents
);
static
void
_gevent_generic_callback
(
struct
ev_loop
*
loop
,
struct
ev_watcher
*
watcher
,
int
revents
);
static
void
gevent_zero_check
(
struct
ev_check
*
handle
);
static
void
gevent_zero_timer
(
struct
ev_timer
*
handle
);
static
void
gevent_zero_prepare
(
struct
ev_prepare
*
handle
);
src/gevent/libev/_corecffi_source.c
View file @
a5f7a836
...
@@ -52,3 +52,18 @@ static void _gevent_generic_callback(struct ev_loop* loop,
...
@@ -52,3 +52,18 @@ static void _gevent_generic_callback(struct ev_loop* loop,
// closing the watcher?
// closing the watcher?
}
}
}
}
static
void
gevent_zero_timer
(
struct
ev_timer
*
handle
)
{
memset
(
handle
,
0
,
sizeof
(
struct
ev_timer
));
}
static
void
gevent_zero_check
(
struct
ev_check
*
handle
)
{
memset
(
handle
,
0
,
sizeof
(
struct
ev_check
));
}
static
void
gevent_zero_prepare
(
struct
ev_prepare
*
handle
)
{
memset
(
handle
,
0
,
sizeof
(
struct
ev_prepare
));
}
src/gevent/libev/corecffi.py
View file @
a5f7a836
...
@@ -265,29 +265,37 @@ class loop(AbstractLoop):
...
@@ -265,29 +265,37 @@ class loop(AbstractLoop):
if
libev
.
ev_is_active
(
self
.
_check
):
if
libev
.
ev_is_active
(
self
.
_check
):
self
.
ref
()
self
.
ref
()
libev
.
ev_check_stop
(
self
.
_ptr
,
self
.
_check
)
libev
.
ev_check_stop
(
self
.
_ptr
,
self
.
_check
)
if
libev
.
ev_is_active
(
self
.
_timer0
):
libev
.
ev_timer_stop
(
self
.
_timer0
)
def
_setup_for_run_callback
(
self
):
def
_setup_for_run_callback
(
self
):
self
.
ref
()
# we should go through the loop now
self
.
ref
()
# we should go through the loop now
def
destroy
(
self
):
def
destroy
(
self
):
if
self
.
_ptr
:
if
self
.
_ptr
:
ptr
=
self
.
_ptr
super
(
loop
,
self
).
destroy
()
should_destroy_loop
=
super
(
loop
,
self
).
destroy
()
if
globals
()[
"__SYSERR_CALLBACK"
]
==
self
.
_handle_syserr
:
if
globals
()[
"__SYSERR_CALLBACK"
]
==
self
.
_handle_syserr
:
set_syserr_cb
(
None
)
set_syserr_cb
(
None
)
if
should_destroy_loop
:
libev
.
ev_loop_destroy
(
ptr
)
def
_can_destroy_loop
(
self
,
ptr
):
def
_can_destroy_loop
(
self
,
ptr
):
# Is it marked as destroyed?
# Is it marked as destroyed?
return
libev
.
ev_userdata
(
ptr
)
return
libev
.
ev_userdata
(
ptr
)
def
_destroy
ed
_loop
(
self
,
ptr
):
def
_destroy_loop
(
self
,
ptr
):
# Mark as destroyed.
# Mark as destroyed.
libev
.
ev_set_userdata
(
ptr
,
ffi
.
NULL
)
libev
.
ev_set_userdata
(
ptr
,
ffi
.
NULL
)
libev
.
ev_loop_destroy
(
ptr
)
libev
.
gevent_zero_prepare
(
self
.
_prepare
)
libev
.
gevent_zero_check
(
self
.
_check
)
libev
.
gevent_zero_timer
(
self
.
_timer0
)
del
self
.
_prepare
del
self
.
_check
del
self
.
_timer0
@
property
@
property
def
MAXPRI
(
self
):
def
MAXPRI
(
self
):
...
...
src/gevent/libuv/loop.py
View file @
a5f7a836
...
@@ -266,17 +266,18 @@ class loop(AbstractLoop):
...
@@ -266,17 +266,18 @@ class loop(AbstractLoop):
self
.
_start_callback_timer
()
self
.
_start_callback_timer
()
libuv
.
uv_ref
(
self
.
_timer0
)
libuv
.
uv_ref
(
self
.
_timer0
)
def
destroy
(
self
):
if
self
.
_ptr
:
def
_can_destroy_loop
(
self
,
ptr
):
ptr
=
self
.
_ptr
# We're being asked to destroy a loop that's,
should_destroy
=
super
(
loop
,
self
).
destroy
()
# at the time it was constructed, was the default loop.
# If loop objects were constructed more than once,
# it may have already been destroyed, though.
# We track this in the data member.
return
ptr
.
data
def
_destroy_loop
(
self
,
ptr
):
ptr
.
data
=
ffi
.
NULL
ptr
.
data
=
ffi
.
NULL
assert
self
.
_ptr
is
None
libuv
.
uv_stop
(
ptr
)
libuv
.
uv_stop
(
ptr
)
if
not
should_destroy
:
# The default loop has already been destroyed.
# libuv likes to abort() the process in this case.
return
libuv
.
gevent_close_all_handles
(
ptr
)
libuv
.
gevent_close_all_handles
(
ptr
)
...
@@ -312,17 +313,6 @@ class loop(AbstractLoop):
...
@@ -312,17 +313,6 @@ class loop(AbstractLoop):
del
self
.
_child_watchers
del
self
.
_child_watchers
def
_can_destroy_loop
(
self
,
ptr
):
# We're being asked to destroy a loop that's,
# at the time it was constructed, was the default loop.
# If loop objects were constructed more than once,
# it may have already been destroyed, though.
# We track this in the data member.
return
ptr
.
data
def
_destroyed_loop
(
self
,
ptr
):
ptr
.
data
=
ffi
.
NULL
def
debug
(
self
):
def
debug
(
self
):
"""
"""
Return all the handles that are open and their ref status.
Return all the handles that are open and their ref status.
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment