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
7fa0f290
Commit
7fa0f290
authored
Nov 10, 2017
by
Jay Oster
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix EPROTOTYPE race condition on macOS [supersedes #1033]
parent
778b8f44
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
15 additions
and
2 deletions
+15
-2
src/gevent/_socket2.py
src/gevent/_socket2.py
+1
-1
src/gevent/_socket3.py
src/gevent/_socket3.py
+1
-1
src/gevent/_socketcommon.py
src/gevent/_socketcommon.py
+13
-0
No files found.
src/gevent/_socket2.py
View file @
7fa0f290
...
...
@@ -322,7 +322,7 @@ class socket(object):
try
:
return
sock
.
send
(
data
,
flags
)
except
error
as
ex
:
if
ex
.
args
[
0
]
!=
EWOULDBLOCK
or
timeout
==
0.0
:
if
ex
.
args
[
0
]
not
in
_socketcommon
.
GSENDAGAIN
or
timeout
==
0.0
:
raise
sys
.
exc_clear
()
self
.
_wait
(
self
.
_write_event
)
...
...
src/gevent/_socket3.py
View file @
7fa0f290
...
...
@@ -389,7 +389,7 @@ class socket(object):
try
:
return
_socket
.
socket
.
send
(
self
.
_sock
,
data
,
flags
)
except
error
as
ex
:
if
ex
.
args
[
0
]
!=
EWOULDBLOCK
or
timeout
==
0.0
:
if
ex
.
args
[
0
]
not
in
_socketcommon
.
GSENDAGAIN
or
timeout
==
0.0
:
raise
self
.
_wait
(
self
.
_write_event
)
try
:
...
...
src/gevent/_socketcommon.py
View file @
7fa0f290
...
...
@@ -78,6 +78,8 @@ from gevent._util import copy_globals
from
gevent._util
import
_NONE
is_windows
=
sys
.
platform
==
'win32'
is_macos
=
sys
.
platform
==
'darwin'
# pylint:disable=no-name-in-module,unused-import
if
is_windows
:
# no such thing as WSAEPERM or error code 10001 according to winsock.h or MSDN
...
...
@@ -102,6 +104,17 @@ try:
except
ImportError
:
EBADF
=
9
# macOS can return EPROTOTYPE when writing to a socket that is shutting
# Down. Retrying the write should return the expected EPIPE error.
# Downstream classes (like pywsgi) know how to handle/ignore EPIPE.
# This set is used by socket.send() to decide whether the write should
# be retried. The default is to retry only on EWOULDBLOCK. Here we add
# EPROTOTYPE on macOS to handle this platform-specific race condition.
GSENDAGAIN
=
(
EWOULDBLOCK
,)
if
is_macos
:
from
errno
import
EPROTOTYPE
GSENDAGAIN
+=
(
EPROTOTYPE
,)
import
_socket
_realsocket
=
_socket
.
socket
import
socket
as
__socket__
...
...
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