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
e5a399f2
Commit
e5a399f2
authored
Feb 24, 2014
by
Denis Bilenko
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #393 from snaury/vfd-win64
Port gevent vfd to win64
parents
3d5c99c1
b8bb5eed
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
36 additions
and
8 deletions
+36
-8
gevent/core.ppyx
gevent/core.ppyx
+6
-1
gevent/libev.pxd
gevent/libev.pxd
+9
-0
gevent/libev_vfd.h
gevent/libev_vfd.h
+21
-7
No files found.
gevent/core.ppyx
View file @
e5a399f2
...
...
@@ -453,8 +453,13 @@ cdef public class loop [object PyGeventLoopObject, type PyGeventLoop_Type]:
CHECK_LOOP3(self)
return libev.ev_pending_count(self._ptr)
#ifdef _WIN32
def io(self, libev.vfd_socket_t fd, int events, ref=True, priority=None):
return io(self, fd, events, ref, priority)
#else
def io(self, int fd, int events, ref=True, priority=None):
return io(self, fd, events, ref, priority)
#endif
def timer(self, double after, double repeat=0.0, ref=True, priority=None):
return timer(self, after, repeat, ref, priority)
...
...
@@ -785,7 +790,7 @@ cdef public class io(watcher) [object PyGeventIOObject, type PyGeventIO_Type]:
#ifdef _WIN32
def __init__(self, loop loop, l
ong
fd, int events, ref=True, priority=None):
def __init__(self, loop loop, l
ibev.vfd_socket_t
fd, int events, ref=True, priority=None):
if events & ~(libev.EV__IOFDSET | libev.EV_READ | libev.EV_WRITE):
raise ValueError('illegal event mask: %r' % events)
cdef int vfd = libev.vfd_open(fd)
...
...
gevent/libev.pxd
View file @
e5a399f2
cdef
extern
from
"libev_vfd.h"
:
#ifdef _WIN32
#ifdef _WIN64
ctypedef
long
long
vfd_socket_t
#else
ctypedef
long
vfd_socket_t
#endif
#else
ctypedef
int
vfd_socket_t
#endif
long
vfd_get
(
int
)
int
vfd_open
(
long
)
except
-
1
void
vfd_free
(
int
)
...
...
gevent/libev_vfd.h
View file @
e5a399f2
#ifdef _WIN32
#ifdef _WIN64
typedef
PY_LONG_LONG
vfd_socket_t
;
#define vfd_socket_object PyLong_FromLongLong
#else
typedef
long
vfd_socket_t
;
#define vfd_socket_object PyInt_FromLong
#endif
#ifdef LIBEV_EMBED
/*
* If libev on win32 is embedded, then we can use an
...
...
@@ -13,7 +20,7 @@
typedef
struct
vfd_entry_t
{
long
handle
;
/* OS handle, i.e. SOCKET */
vfd_socket_t
handle
;
/* OS handle, i.e. SOCKET */
int
count
;
/* Reference count, 0 if free */
int
next
;
/* Next free fd, -1 if last */
}
vfd_entry
;
...
...
@@ -58,7 +65,7 @@ static CRITICAL_SECTION* vfd_make_lock()
* Given a virtual fd returns an OS handle or -1
* This function is speed critical, so it cannot use GIL
*/
static
long
vfd_get
(
int
fd
)
static
vfd_socket_t
vfd_get
(
int
fd
)
{
int
handle
=
-
1
;
VFD_LOCK_ENTER
;
...
...
@@ -74,7 +81,7 @@ static long vfd_get(int fd)
* Given an OS handle finds or allocates a virtual fd
* Returns -1 on failure and sets Python exception if pyexc is non-zero
*/
static
int
vfd_open_
(
long
handle
,
int
pyexc
)
static
int
vfd_open_
(
vfd_socket_t
handle
,
int
pyexc
)
{
VFD_GIL_DECLARE
;
int
fd
=
-
1
;
...
...
@@ -87,7 +94,13 @@ static int vfd_open_(long handle, int pyexc)
}
if
(
ioctlsocket
(
handle
,
FIONREAD
,
&
arg
)
!=
0
)
{
if
(
pyexc
)
PyErr_Format
(
PyExc_IOError
,
"%ld is not a socket (files are not supported)"
,
handle
);
PyErr_Format
(
PyExc_IOError
,
#ifdef _WIN64
"%lld is not a socket (files are not supported)"
,
#else
"%ld is not a socket (files are not supported)"
,
#endif
handle
);
goto
done
;
}
if
(
vfd_map
==
NULL
)
{
...
...
@@ -95,7 +108,7 @@ static int vfd_open_(long handle, int pyexc)
if
(
vfd_map
==
NULL
)
goto
done
;
}
key
=
PyLong_FromLong
(
handle
);
key
=
vfd_socket_object
(
handle
);
/* check if it's already in the dict */
value
=
PyDict_GetItem
(
vfd_map
,
key
);
if
(
value
!=
NULL
)
{
...
...
@@ -168,14 +181,14 @@ static void vfd_free_(int fd, int needclose)
goto
done
;
/* free entry, ignore */
if
(
!--
vfd_entries
[
fd
].
count
)
{
/* fd has just been freed */
long
handle
=
vfd_entries
[
fd
].
handle
;
vfd_socket_t
handle
=
vfd_entries
[
fd
].
handle
;
vfd_entries
[
fd
].
handle
=
-
1
;
vfd_entries
[
fd
].
next
=
vfd_next
;
vfd_next
=
fd
;
if
(
needclose
)
closesocket
(
handle
);
/* vfd_map is assumed to be != NULL */
key
=
PyLong_FromLong
(
handle
);
key
=
vfd_socket_object
(
handle
);
PyDict_DelItem
(
vfd_map
,
key
);
Py_DECREF
(
key
);
}
...
...
@@ -203,6 +216,7 @@ done:
/*
* On non-win32 platforms vfd_* are noop macros
*/
typedef
int
vfd_socket_t
;
#define vfd_get(fd) (fd)
#define vfd_open(fd) ((int)(fd))
#define vfd_free(fd)
...
...
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