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
9bb23a79
Commit
9bb23a79
authored
Apr 03, 2011
by
Denis Bilenko
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
in gevent_callback expect args to be None or non-tuple (check the return value of PyTuple_Size)
parent
c285538a
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
8 deletions
+17
-8
gevent/callbacks.c
gevent/callbacks.c
+17
-8
No files found.
gevent/callbacks.c
View file @
9bb23a79
...
@@ -74,28 +74,37 @@ static inline void gevent_stop(struct PyGeventTimerObject* watcher) {
...
@@ -74,28 +74,37 @@ static inline void gevent_stop(struct PyGeventTimerObject* watcher) {
static
void
gevent_callback
(
struct
ev_loop
*
_loop
,
void
*
c_watcher
,
int
revents
)
{
static
void
gevent_callback
(
struct
ev_loop
*
_loop
,
void
*
c_watcher
,
int
revents
)
{
struct
PyGeventTimerObject
*
watcher
;
struct
PyGeventTimerObject
*
watcher
;
PyObject
*
result
,
*
py_events
;
PyObject
*
result
,
*
py_events
,
*
args
;
long
length
;
GIL_ENSURE
;
GIL_ENSURE
;
/* we use this callback for all watchers, not just timer
/* 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 */
* we can do this, because layout of struct members is the same for all watchers */
watcher
=
((
struct
PyGeventTimerObject
*
)(((
char
*
)
c_watcher
)
-
timer_offsetof
));
watcher
=
((
struct
PyGeventTimerObject
*
)(((
char
*
)
c_watcher
)
-
timer_offsetof
));
Py_INCREF
(
watcher
);
Py_INCREF
(
watcher
);
gevent_check_signals
(
watcher
->
loop
);
gevent_check_signals
(
watcher
->
loop
);
if
(
PyTuple_Size
(
watcher
->
args
)
>
0
&&
PyTuple_GET_ITEM
(
watcher
->
args
,
0
)
==
GEVENT_CORE_EVENTS
)
{
args
=
watcher
->
args
;
if
(
args
==
Py_None
)
{
args
=
__pyx_empty_tuple
;
}
length
=
PyTuple_Size
(
args
);
if
(
length
<
0
)
{
gevent_handle_error
(
watcher
->
loop
,
(
PyObject
*
)
watcher
);
goto
end
;
}
if
(
length
>
0
&&
PyTuple_GET_ITEM
(
args
,
0
)
==
GEVENT_CORE_EVENTS
)
{
py_events
=
PyInt_FromLong
(
revents
);
py_events
=
PyInt_FromLong
(
revents
);
if
(
py_events
)
{
if
(
!
py_events
)
{
Py_DECREF
(
GEVENT_CORE_EVENTS
);
PyTuple_SET_ITEM
(
watcher
->
args
,
0
,
py_events
);
}
else
{
gevent_handle_error
(
watcher
->
loop
,
(
PyObject
*
)
watcher
);
gevent_handle_error
(
watcher
->
loop
,
(
PyObject
*
)
watcher
);
goto
end
;
goto
end
;
}
}
Py_DECREF
(
GEVENT_CORE_EVENTS
);
PyTuple_SET_ITEM
(
args
,
0
,
py_events
);
}
}
else
{
else
{
py_events
=
NULL
;
py_events
=
NULL
;
}
}
result
=
PyObject_Call
(
watcher
->
_callback
,
watcher
->
args
!=
Py_None
?
watcher
->
args
:
__pyx_empty_tuple
,
NULL
);
// should incref args?
result
=
PyObject_Call
(
watcher
->
_callback
,
args
,
NULL
);
if
(
result
)
{
if
(
result
)
{
Py_DECREF
(
result
);
Py_DECREF
(
result
);
}
}
...
...
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