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
1a507dd9
Commit
1a507dd9
authored
May 22, 2011
by
Alexey Borzenkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix c-ares on Windows + other fixes
parent
1f8b3a79
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
105 additions
and
7 deletions
+105
-7
c-ares/ares_writev.c
c-ares/ares_writev.c
+79
-0
gevent/core_.pyx
gevent/core_.pyx
+20
-3
gevent/libev.pxd
gevent/libev.pxd
+2
-0
setup.py
setup.py
+4
-4
No files found.
c-ares/ares_writev.c
0 → 100644
View file @
1a507dd9
/* Copyright 1998 by the Massachusetts Institute of Technology.
*
* Permission to use, copy, modify, and distribute this
* software and its documentation for any purpose and without
* fee is hereby granted, provided that the above copyright
* notice appear in all copies and that both that copyright
* notice and this permission notice appear in supporting
* documentation, and that the name of M.I.T. not be used in
* advertising or publicity pertaining to distribution of the
* software without specific, written prior permission.
* M.I.T. makes no representations about the suitability of
* this software for any purpose. It is provided "as is"
* without express or implied warranty.
*/
#include "ares_setup.h"
#ifdef HAVE_LIMITS_H
# include <limits.h>
#endif
#include "ares.h"
#include "ares_private.h"
#ifndef HAVE_WRITEV
ssize_t
ares_writev
(
ares_socket_t
s
,
const
struct
iovec
*
iov
,
int
iovcnt
)
{
char
*
buffer
,
*
bp
;
int
i
;
size_t
bytes
=
0
;
ssize_t
result
;
/* Validate iovcnt */
if
(
iovcnt
<=
0
)
{
SET_ERRNO
(
EINVAL
);
return
(
-
1
);
}
/* Validate and find the sum of the iov_len values in the iov array */
for
(
i
=
0
;
i
<
iovcnt
;
i
++
)
{
if
(
iov
[
i
].
iov_len
>
INT_MAX
-
bytes
)
{
SET_ERRNO
(
EINVAL
);
return
(
-
1
);
}
bytes
+=
iov
[
i
].
iov_len
;
}
if
(
bytes
==
0
)
return
(
0
);
/* Allocate a temporary buffer to hold the data */
buffer
=
malloc
(
bytes
);
if
(
!
buffer
)
{
SET_ERRNO
(
ENOMEM
);
return
(
-
1
);
}
/* Copy the data into buffer */
for
(
bp
=
buffer
,
i
=
0
;
i
<
iovcnt
;
++
i
)
{
memcpy
(
bp
,
iov
[
i
].
iov_base
,
iov
[
i
].
iov_len
);
bp
+=
iov
[
i
].
iov_len
;
}
/* Send buffer contents */
result
=
swrite
(
s
,
buffer
,
bytes
);
free
(
buffer
);
return
(
result
);
}
#endif
gevent/core_.pyx
100755 → 100644
View file @
1a507dd9
...
...
@@ -448,7 +448,7 @@ define(WATCHER, `WATCHER_BASE($1)
ACTIVE($1)'
)
define
(
INIT
,
`
def
__init__
(
self
,
loop
loop
$
2
):
define
(
INIT
,
`
def
__
c
init__
(
self
,
loop
loop
$
2
):
libev
.
ev_
$
1
_init
(
&
self
.
_watcher
,
<
void
*>
gevent_callback_
$
1
$
3
)
self
.
loop
=
loop
self
.
_incref
=
0
')
...
...
@@ -498,22 +498,39 @@ cdef public class io(watcher) [object PyGeventIOObject, type PyGeventIO_Type]:
WATCHER(io)
def __init__(self, loop loop, int fd, int events):
cdef int _initialized # for __dealloc__, whether io is initialized
def __cinit__(self, loop loop, int fd, int events):
IFDEF_WINDOWS()
fd = _open_osfhandle(fd)
ENDIF()
libev.ev_io_init(&self._watcher, <void *>gevent_callback_io, fd, events)
self._initialized = 1
self.loop = loop
self._incref = 0
def __dealloc__(self):
IFDEF_WINDOWS()
if self._initialized:
libev.close(self._watcher.fd)
ENDIF()
property fd:
def __get__(self):
return self._watcher.fd
cdef int fd = self._watcher.fd
IFDEF_WINDOWS()
fd = libev._get_osfhandle(fd)
ENDIF()
return fd
def __set__(self, int fd):
if libev.ev_is_active(&self._watcher):
raise AttributeError("'
io
' watcher attribute '
fd
' is read-only while watcher is active")
IFDEF_WINDOWS()
fd = _open_osfhandle(fd) # careful, might raise
libev.close(self._watcher.fd) # close the old one
ENDIF()
libev.ev_io_init(&self._watcher, <void *>gevent_callback_io, fd, self._watcher.events)
property events:
...
...
gevent/libev.pxd
View file @
1a507dd9
...
...
@@ -131,3 +131,5 @@ cdef extern from "libev.h":
# not from libev, but it's there to avoid collisions with gevent.core._open_osfhandle
int
_open_osfhandle
(
int
,
int
)
int
_get_osfhandle
(
int
)
void
close
(
int
)
setup.py
100755 → 100644
View file @
1a507dd9
...
...
@@ -59,6 +59,8 @@ if os.path.exists('libev'):
def
need_configure_ares
():
if
sys
.
platform
==
'win32'
:
return
False
if
'Generated from ares_build.h.in by configure'
not
in
read
(
'c-ares/ares_build.h'
):
return
True
if
not
os
.
path
.
exists
(
'c-ares/ares_config.h'
):
...
...
@@ -96,12 +98,13 @@ if ares_embed:
ARES
.
sources
+=
sorted
(
glob
(
'c-ares/*.c'
))
if
sys
.
platform
==
'win32'
:
ARES
.
libraries
+=
[
'advapi32'
]
ARES
.
define_macros
+=
[(
'CARES_STATICLIB'
,
''
)]
else
:
ARES
.
configure
=
configure_ares
ARES
.
define_macros
+=
[(
'HAVE_CONFIG_H'
,
''
)]
ARES
.
define_macros
+=
[(
'CARES_EMBED'
,
''
)]
if
sys
.
platform
!=
'darwin'
:
ARES
.
libraries
+=
[
'rt'
]
ARES
.
define_macros
+=
[(
'CARES_EMBED'
,
''
)]
def
need_update
(
destination
,
*
source
):
...
...
@@ -221,9 +224,6 @@ def read(name):
ext_modules
=
[
CORE
,
ARES
]
if
sys
.
platform
in
(
'win32'
):
# XXX currently does not work
ext_modules
.
remove
(
ARES
)
warnings
=
[]
def
warn
(
message
):
...
...
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