Victor Stinner
ec1a498a01
Issue #24684 : socket.socket.getaddrinfo() now calls
PyUnicode_AsEncodedString() instead of calling the encode() method of the
host, to handle correctly custom string with an encode() method which doesn't
return a byte string. The encoder of the IDNA codec is now called directly
instead of calling the encode() method of the string.
10 years ago
Victor Stinner
bea232a15f
Issue #24732 , #23834 : Fix sock_accept_impl() on Windows
accept() returns INVALID_SOCKET on error, it's not necessary a negative number.
11 years ago
Larry Hastings
a6cc551502
Issue #22631 : Added Linux-specific socket constant CAN_RAW_FD_FRAMES.
Patch courtesy of Joe Jevnik.
11 years ago
Victor Stinner
8e44aa5ae4
Issue #23834 : Fix socket.sendto(), use the C Py_ssize_t type to store the
result of sendto() instead of the C int type.
11 years ago
Benjamin Peterson
4fd929b431
remove assignment in conditional
11 years ago
Victor Stinner
ced1174525
Issue #23618 : Fix internal_select() for negative timeout (blocking socket) when
poll() is not available.
select() doesn't accept negative timeout, the timeout parameter must be NULL to
block on select().
11 years ago
Victor Stinner
88ed640fc7
Issue #23834 : Fix the default socket timeout
Use -1 second by default, not -1 nanosecond.
11 years ago
Victor Stinner
222dfc7d94
Issue #22117 : Fix sock_call_ex() for non-blocking socket
Call internal_select() with a timeout of 0 second, not a timeout of -1 second
(blocking)!
11 years ago
Victor Stinner
8912d1418e
Issue #23853 : socket.socket.sendall() does no more reset the socket timeout
each time data is sent successfuly. The socket timeout is now the maximum total
duration to send all data.
11 years ago
Victor Stinner
9001d8089c
Issue #23834 : Fix initial value of the socket timeout
Use _PyTime_FromSeconds() to initialize the default socket timeout to -1
second, instead of -1 nanosecond which causes rounding issues in
internal_select().
11 years ago
Victor Stinner
10550cdb8a
Issue #23834 : Simplify timeout handling
* Use the new _PyTime_FromSeconds() function to set the timeout to -1 second
for socket.settimeout(None). It avoids a special case in internal_select()
because of a rounding issue: -1 nanosecond is rounded to 0 millisecond which
means non-blocking, instead of blocking.
* Check if the interval the negative in sock_call_ex() instead of doing the
check in internal_select(). sock_call_ex() remembers if the socket has a
timeout or not, which avoids a race condition if the timeout is modified in a
different thread.
11 years ago
Victor Stinner
a135cb8143
Issue #23618 : Ooops, remove abort() added for debug purpose
11 years ago
Victor Stinner
38aec7525e
Issue #23618 : Fix sock_connect_impl(), set the socket error code
sock_call_ex() gets the socket error code when the socket function fails.
sock_connect_impl() didn't set the error correctly.
11 years ago
Victor Stinner
81c41dbfcc
Issue #23618 : socket.socket.connect() now waits until the connection completes
instead of raising InterruptedError if the connection is interrupted by
signals, signal handlers don't raise an exception and the socket is blocking or
has a timeout.
socket.socket.connect() still raise InterruptedError for non-blocking sockets.
11 years ago
Victor Stinner
35bee932e4
Issue #23618 : Don't declare recvmsg/sendmsg helper functions on Windows
11 years ago
Victor Stinner
ff444e828e
Issue #23834 : Fix sock_call(), set deadline_initialized to recompute the timeout
11 years ago
Victor Stinner
02f32ab47e
Issue #23834 : Modify socket.sendall() to reuse sock_call() with
sock_send_impl()
11 years ago
Victor Stinner
31bf2d5073
Issue #23834 : Add sock_call() helper function
The BEGIN_SELECT_LOOP and END_SELECT_LOOP macros of socketmodule.c don't handle
EINTR. Functions using these macros use an inner loop to handle EINTR, but they
don't recompute the timeout.
This changes replaces the two macros with a new sock_call() function which
takes a function as a parameter. sock_call() recomputes the timeout, handle
false positive and handle EINTR.
11 years ago
Victor Stinner
a772662423
Issue #23618 : Fix EINTR handling on Windows
Windows uses WSAEINTR error code, not EINTR, for socket functions.
11 years ago
Victor Stinner
70a46f635f
Issue #23618 : Enhance EINTR handling in socket.connect()
Call PyErr_CheckSignals() immediatly if connect() or select() fails with EINTR
in internal_connect().
Refactor also the code to limit indentaton and make it more readable.
11 years ago
Victor Stinner
ee699e9d2b
Issue #23618 : Fix EINTR handling in socket.connect()
Call PyErr_CheckSignals() if connect(), select() or getsockopt() failed with
EINTR.
11 years ago
Victor Stinner
c4e819a54f
Issue #23618 : Cleanup internal_connect() in socketmodule.c
On Windows, it looks like using the C type socklen_t for getsockopt() (instead
of int) is fine, it was already used in socket.getsockopt().
11 years ago
Victor Stinner
b6c15bcad3
Issue #23618 : Refactor internal_connect()
On Windows, internal_connect() now reuses internal_connect_select() and always
calls getsockopt().
11 years ago
Victor Stinner
dd88d3db45
Issue #23618 : Refactor internal_connect()
The function now returns the error code instead of using the global errno
(POSIX) or WSAGetLastError() (Windows).
internal_connect() now returns errno if getsockopt() fails.
11 years ago
Victor Stinner
1bb0aef4d1
Issue #22117 : Fix integer overflow check in socket_parse_timeout() on Windows
11 years ago
Victor Stinner
dd83bd2f9c
Issue #23618 : Fix internal_connect_select()
11 years ago
Victor Stinner
416f2e66ca
Issue #23618 : internal_connect_select() now waits also for error events
11 years ago
Victor Stinner
e6951c6c8a
Issue #23618 : Refactor internal_select() to prepare socket.connect() for EINTR
11 years ago
Victor Stinner
391fa713f7
Issue #23618 : Refactor the _socket module
* Inline internal_select() function
* Rename internal_select_ex() internal_select()
11 years ago
Victor Stinner
869e1778c0
Issue #22117 : Replace usage of _PyTime_ROUND_UP with _PyTime_ROUND_CEILING
All these functions only accept positive timeouts, so this change has no effect
in practice.
11 years ago
Victor Stinner
ea9c0dd2c2
Issue #22117 : Fix usage of _PyTime_AsTimeval()
Add _PyTime_AsTimeval_noraise() function. Call it when it's not possible (or
not useful) to raise a Python exception on overflow.
11 years ago
Victor Stinner
71694d5c8c
Issue #22117 : The socket module uses _PyTime_t timestamp for timeouts
11 years ago
Victor Stinner
b7df3144ef
Issue #23618 , #22117 : refactor socketmodule.c
Move Py_BEGIN_ALLOW_THREADS/Py_END_ALLOW_THREADS inside internal_select_ex() to
prepare a switch to the _PyTime_t type and retry syscall on EINTR.
11 years ago
Victor Stinner
f50e187724
Fix compiler warnings: comparison between signed and unsigned numbers
11 years ago
Serhiy Storchaka
8490f5acfe
Issue #23001 : Few functions in modules mmap, ossaudiodev, socket, ssl, and
codecs, that accepted only read-only bytes-like object now accept writable
bytes-like object too.
11 years ago
Victor Stinner
9a8089b32a
Issue #23646 : Enhance precision of time.sleep() and socket timeout when
interrupted by a signal
Add a new _PyTime_AddDouble() function and remove _PyTime_ADD_SECONDS() macro.
The _PyTime_ADD_SECONDS only supported an integer number of seconds, the
_PyTime_AddDouble() has subsecond resolution.
11 years ago
Serhiy Storchaka
caa01f861c
Fixed GCC version testing.
11 years ago
Victor Stinner
a4c727131e
Fix "GCC diagnostic" in socketmodule.c
Fix regression of changeset 7c6e3358221a on GCC < 4.4. The _socket module
cannot be compiled on "x86 FreeBSD 7.2 3.x" buildbot anymore.
11 years ago
Serhiy Storchaka
b48af340b9
Silenced minor GCC warnings.
11 years ago
Serhiy Storchaka
1a1ff29659
Issue #23446 : Use PyMem_New instead of PyMem_Malloc to avoid possible integer
overflows. Added few missed PyErr_NoMemory().
11 years ago
Charles-François Natali
6e6c59b508
Issue #23285 : PEP 475 -- Retry system calls failing with EINTR.
11 years ago
Serhiy Storchaka
b757c83ec6
Issue #22581 : Use more "bytes-like object" throughout the docs and comments.
11 years ago
Steve Dower
65e4cb10d9
Issue #22919 : Windows build updated to support VC 14.0 (Visual Studio 2015), which will be used for the official 3.5 release.
11 years ago
Charles-François Natali
ea07eb9469
Issue #22378 : socket module: add SO_MARK.
11 years ago
Serhiy Storchaka
d8a1447c99
Issue #22215 : Now ValueError is raised instead of TypeError when str or bytes
argument contains not permitted null character or byte.
11 years ago
Victor Stinner
ae58649721
Issue #22043 : time.monotonic() is now always available
threading.Lock.acquire(), threading.RLock.acquire() and socket operations now
use a monotonic clock, instead of the system clock, when a timeout is used.
12 years ago
Victor Stinner
1a62a680d6
Issue #22218 : Fix "comparison between signed and unsigned integers" warnings in
socketmodule.c.
12 years ago
Martin v. Löwis
17fd1e1013
Issue #22127 : fix typo.
12 years ago
Martin v. Löwis
eb1c28a849
Issue #22127 : Bypass IDNA for pure-ASCII host names (in particular for numeric IPs).
12 years ago
Victor Stinner
e254e53c83
Fix repr(_socket.socket) on Windows 64-bit: don't fail with OverflowError
on closed socket. repr(socket.socket) already works fine.
12 years ago