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
85543b2c
Commit
85543b2c
authored
Apr 25, 2011
by
Denis Bilenko
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix crash in core
parent
6babe9ad
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
7 deletions
+11
-7
gevent/callbacks.c
gevent/callbacks.c
+11
-7
No files found.
gevent/callbacks.c
View file @
85543b2c
...
...
@@ -76,6 +76,7 @@ static void gevent_callback(struct ev_loop *_loop, void *c_watcher, int revents)
struct
PyGeventTimerObject
*
watcher
;
PyObject
*
result
,
*
py_events
,
*
args
;
long
length
;
py_events
=
0
;
GIL_ENSURE
;
/* we use this callback for all watchers, not just timer
* we can do this, because layout of struct members is the same for all watchers */
...
...
@@ -86,6 +87,7 @@ static void gevent_callback(struct ev_loop *_loop, void *c_watcher, int revents)
if
(
args
==
Py_None
)
{
args
=
__pyx_empty_tuple
;
}
Py_INCREF
(
args
);
length
=
PyTuple_Size
(
args
);
if
(
length
<
0
)
{
gevent_handle_error
(
watcher
->
loop
,
(
PyObject
*
)
watcher
);
...
...
@@ -103,8 +105,8 @@ static void gevent_callback(struct ev_loop *_loop, void *c_watcher, int revents)
else
{
py_events
=
NULL
;
}
/*
no need to incref 'args'; PyEval_EvalCodeEx which eventually will be called will
*
increase the reference of every element in args
*/
/*
The callback can clear watcher->args and thus drop reference of args to zero;
*
that's why we need to incref args above.
*/
result
=
PyObject_Call
(
watcher
->
_callback
,
args
,
NULL
);
if
(
result
)
{
Py_DECREF
(
result
);
...
...
@@ -114,19 +116,21 @@ static void gevent_callback(struct ev_loop *_loop, void *c_watcher, int revents)
if
(
revents
&
(
EV_READ
|
EV_WRITE
))
{
/* this was an 'io' watcher: not stopping it will likely to cause the failing callback to be called repeatedly */
gevent_stop
(
watcher
);
goto
end
;
}
}
if
(
py_events
)
{
Py_DECREF
(
py_events
);
Py_INCREF
(
GEVENT_CORE_EVENTS
);
PyTuple_SET_ITEM
(
watcher
->
args
,
0
,
GEVENT_CORE_EVENTS
);
}
if
(
!
ev_is_active
(
c_watcher
))
{
/* watcher will never be run again: calling stop() will clear 'callback' and 'args' */
gevent_stop
(
watcher
);
}
end:
if
(
py_events
)
{
Py_DECREF
(
py_events
);
Py_INCREF
(
GEVENT_CORE_EVENTS
);
PyTuple_SET_ITEM
(
args
,
0
,
GEVENT_CORE_EVENTS
);
}
Py_DECREF
((
PyObject
*
)
watcher
);
Py_DECREF
(
args
);
GIL_RELEASE
;
}
...
...
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