Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
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
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
02f32ab4
Commit
02f32ab4
authored
Apr 01, 2015
by
Victor Stinner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Issue #23834: Modify socket.sendall() to reuse sock_call() with
sock_send_impl()
parent
31bf2d50
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
29 deletions
+21
-29
Modules/socketmodule.c
Modules/socketmodule.c
+21
-29
No files found.
Modules/socketmodule.c
View file @
02f32ab4
...
...
@@ -3501,10 +3501,10 @@ static PyObject *
sock_sendall
(
PySocketSockObject
*
s
,
PyObject
*
args
)
{
char
*
buf
;
Py_ssize_t
len
,
n
=
-
1
;
int
async_err
=
0
;
int
flags
=
0
,
timeout
;
Py_ssize_t
len
,
n
;
int
flags
=
0
;
Py_buffer
pbuf
;
struct
sock_send
ctx
;
if
(
!
PyArg_ParseTuple
(
args
,
"y*|i:sendall"
,
&
pbuf
,
&
flags
))
return
NULL
;
...
...
@@ -3517,38 +3517,30 @@ sock_sendall(PySocketSockObject *s, PyObject *args)
}
do
{
timeout
=
internal_select
(
s
,
1
,
s
->
sock_timeout
);
n
=
-
1
;
if
(
!
timeout
)
{
Py_BEGIN_ALLOW_THREADS
#ifdef MS_WINDOWS
if
(
len
>
INT_MAX
)
len
=
INT_MAX
;
n
=
send
(
s
->
sock_fd
,
buf
,
(
int
)
len
,
flags
);
#else
n
=
send
(
s
->
sock_fd
,
buf
,
len
,
flags
);
#endif
Py_END_ALLOW_THREADS
}
if
(
timeout
==
1
)
{
ctx
.
buf
=
buf
;
ctx
.
len
=
len
;
ctx
.
flags
=
flags
;
if
(
sock_call
(
s
,
1
,
sock_send_impl
,
&
ctx
)
<
0
)
{
PyBuffer_Release
(
&
pbuf
);
PyErr_SetString
(
socket_timeout
,
"timed out"
);
return
NULL
;
}
if
(
n
>=
0
)
{
n
=
ctx
.
result
;
assert
(
n
>=
0
);
buf
+=
n
;
len
-=
n
;
/* We must run our signal handlers before looping again.
send() can return a successful partial write when it is
interrupted, so we can't restrict ourselves to EINTR. */
if
(
PyErr_CheckSignals
())
{
PyBuffer_Release
(
&
pbuf
);
return
NULL
;
}
}
while
(
len
>
0
&&
(
n
>=
0
||
errno
==
EINTR
)
&&
!
(
async_err
=
PyErr_CheckSignals
()));
}
while
(
len
>
0
);
PyBuffer_Release
(
&
pbuf
);
if
(
n
<
0
||
async_err
)
return
(
!
async_err
)
?
s
->
errorhandler
()
:
NULL
;
Py_INCREF
(
Py_None
);
return
Py_None
;
Py_RETURN_NONE
;
}
PyDoc_STRVAR
(
sendall_doc
,
...
...
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