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
2dc8f3ac
Commit
2dc8f3ac
authored
Dec 08, 2017
by
Jason Madden
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Attempt to smuggle SOCKET through to uv_poll_init_socket on windows.
parent
344541af
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
23 additions
and
6 deletions
+23
-6
src/gevent/libuv/_corecffi_build.py
src/gevent/libuv/_corecffi_build.py
+6
-1
src/gevent/libuv/_corecffi_cdef.c
src/gevent/libuv/_corecffi_cdef.c
+10
-4
src/gevent/libuv/watcher.py
src/gevent/libuv/watcher.py
+7
-1
No files found.
src/gevent/libuv/_corecffi_build.py
View file @
2dc8f3ac
...
@@ -45,7 +45,12 @@ _cdef = _cdef.replace('#define GEVENT_UV_OS_SOCK_T int', '')
...
@@ -45,7 +45,12 @@ _cdef = _cdef.replace('#define GEVENT_UV_OS_SOCK_T int', '')
_cdef
=
_cdef
.
replace
(
'GEVENT_ST_NLINK_T'
,
st_nlink_type
())
_cdef
=
_cdef
.
replace
(
'GEVENT_ST_NLINK_T'
,
st_nlink_type
())
_cdef
=
_cdef
.
replace
(
"GEVENT_STRUCT_DONE _;"
,
'...;'
)
_cdef
=
_cdef
.
replace
(
"GEVENT_STRUCT_DONE _;"
,
'...;'
)
_cdef
=
_cdef
.
replace
(
"GEVENT_UV_OS_SOCK_T"
,
'int'
if
not
WIN
else
'SOCKET'
)
# uv_os_sock_t is int on POSIX and SOCKET on Win32, but socket is
# just another name for handle, which is just another name for 'void*'
# which we will treat as an 'unsigned long' or 'unsigned long long'
# since it comes through 'fileno()' where it has been cast as an int.
_void_pointer_as_integer
=
'unsigned long'
if
system_bits
()
==
32
else
'unsigned long long'
_cdef
=
_cdef
.
replace
(
"GEVENT_UV_OS_SOCK_T"
,
'int'
if
not
WIN
else
_void_pointer_as_integer
)
setup_py_dir
=
os
.
path
.
abspath
(
os
.
path
.
join
(
thisdir
,
'..'
,
'..'
,
'..'
))
setup_py_dir
=
os
.
path
.
abspath
(
os
.
path
.
join
(
thisdir
,
'..'
,
'..'
,
'..'
))
...
...
src/gevent/libuv/_corecffi_cdef.c
View file @
2dc8f3ac
...
@@ -300,10 +300,16 @@ int uv_signal_stop(uv_signal_t *handle);
...
@@ -300,10 +300,16 @@ int uv_signal_stop(uv_signal_t *handle);
// Unix any file descriptor that would be accepted by poll(2) can be
// Unix any file descriptor that would be accepted by poll(2) can be
// used.
// used.
int
uv_poll_init
(
uv_loop_t
*
loop
,
uv_poll_t
*
handle
,
int
fd
);
int
uv_poll_init
(
uv_loop_t
*
loop
,
uv_poll_t
*
handle
,
int
fd
);
// Initialize the handle using a socket descriptor. On Unix this is identical to uv_poll_init(). On windows it takes a SOCKET handle.
// The socket is set to non-blocking mode.
// Initialize the handle using a socket descriptor. On Unix this is
// On Windows, how to get the SOCKET type defined?
// identical to uv_poll_init(). On windows it takes a SOCKET handle;
//int uv_poll_init_socket(uv_loop_t* loop, uv_poll_t* handle, GEVENT_UV_OS_SOCK_T socket);
// SOCKET handles are another name for HANDLE objects in win32, and
// those are defined as PVOID, even though they are not actually
// pointers (they're small integers). CPython and PyPy both return
// the SOCKET (as cast to an int) from the socket.fileno() method.
// libuv uses ``uv_os_sock_t`` for this type, which is defined as an
// int on unix.
int
uv_poll_init_socket
(
uv_loop_t
*
loop
,
uv_poll_t
*
handle
,
GEVENT_UV_OS_SOCK_T
socket
);
int
uv_poll_start
(
uv_poll_t
*
handle
,
int
events
,
uv_poll_cb
cb
);
int
uv_poll_start
(
uv_poll_t
*
handle
,
int
events
,
uv_poll_cb
cb
);
int
uv_poll_stop
(
uv_poll_t
*
handle
);
int
uv_poll_stop
(
uv_poll_t
*
handle
);
...
...
src/gevent/libuv/watcher.py
View file @
2dc8f3ac
...
@@ -3,6 +3,7 @@
...
@@ -3,6 +3,7 @@
from
__future__
import
absolute_import
,
print_function
from
__future__
import
absolute_import
,
print_function
import
functools
import
functools
import
sys
import
weakref
import
weakref
import
gevent.libuv._corecffi
as
_corecffi
# pylint:disable=no-name-in-module,import-error
import
gevent.libuv._corecffi
as
_corecffi
# pylint:disable=no-name-in-module,import-error
...
@@ -28,7 +29,6 @@ def _dbg(*args, **kwargs):
...
@@ -28,7 +29,6 @@ def _dbg(*args, **kwargs):
def
_pid_dbg
(
*
args
,
**
kwargs
):
def
_pid_dbg
(
*
args
,
**
kwargs
):
import
os
import
os
import
sys
kwargs
[
'file'
]
=
sys
.
stderr
kwargs
[
'file'
]
=
sys
.
stderr
print
(
os
.
getpid
(),
*
args
,
**
kwargs
)
print
(
os
.
getpid
(),
*
args
,
**
kwargs
)
...
@@ -224,6 +224,12 @@ class io(_base.IoMixin, watcher):
...
@@ -224,6 +224,12 @@ class io(_base.IoMixin, watcher):
def
_watcher_ffi_start
(
self
):
def
_watcher_ffi_start
(
self
):
self
.
_watcher_start
(
self
.
_watcher
,
self
.
_events
,
self
.
_watcher_callback
)
self
.
_watcher_start
(
self
.
_watcher
,
self
.
_events
,
self
.
_watcher_callback
)
if
sys
.
platform
.
startswith
(
'win32'
):
# We can only handle sockets. We smuggle the SOCKET through disguised
# as a fileno
_watcher_init
=
watcher
.
_LIB
.
uv_poll_init_socket
class
_multiplexwatcher
(
object
):
class
_multiplexwatcher
(
object
):
def
__init__
(
self
,
events
,
watcher
):
def
__init__
(
self
,
events
,
watcher
):
...
...
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