Victor Stinner
bc5b80bac1
Close #24784 : Fix compilation without thread support
...
Add "#ifdef WITH_THREAD" around cals to:
* PyGILState_Check()
* _PyImport_AcquireLock()
* _PyImport_ReleaseLock()
2015-10-11 09:54:42 +02:00
Victor Stinner
f9fdfa7c4e
Merge 3.4
2015-09-11 12:38:17 +02:00
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.
2015-09-11 12:37:30 +02:00
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.
2015-07-27 23:37:11 +02:00
Larry Hastings
a6cc551502
Issue #22631 : Added Linux-specific socket constant CAN_RAW_FD_FRAMES.
...
Patch courtesy of Joe Jevnik.
2015-04-13 17:48:40 -04:00
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().
2015-04-09 10:27:25 +02:00
Victor Stinner
88ed640fc7
Issue #23834 : Fix the default socket timeout
...
Use -1 second by default, not -1 nanosecond.
2015-04-09 10:23:12 +02:00
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)!
2015-04-06 22:30:41 +02:00
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.
2015-04-06 23:16:34 +02:00
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().
2015-04-06 23:06:01 +02:00
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.
2015-04-03 13:22:27 +02:00
Victor Stinner
a135cb8143
Issue #23618 : Ooops, remove abort() added for debug purpose
2015-04-02 15:17:12 +02:00
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.
2015-04-02 14:37:20 +02:00
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.
2015-04-02 11:50:57 +02:00
Victor Stinner
35bee932e4
Issue #23618 : Don't declare recvmsg/sendmsg helper functions on Windows
2015-04-02 12:28:07 +02:00
Victor Stinner
ff444e828e
Issue #23834 : Fix sock_call(), set deadline_initialized to recompute the timeout
2015-04-02 03:22:49 +02:00
Victor Stinner
02f32ab47e
Issue #23834 : Modify socket.sendall() to reuse sock_call() with
...
sock_send_impl()
2015-04-01 22:53:26 +02:00
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.
2015-04-01 21:57:09 +02:00
Benjamin Peterson
81541f4480
merge 3.4
2015-04-01 12:37:34 -04:00
Benjamin Peterson
4fd929b431
remove assignment in conditional
2015-04-01 11:16:40 -04:00
Victor Stinner
a772662423
Issue #23618 : Fix EINTR handling on Windows
...
Windows uses WSAEINTR error code, not EINTR, for socket functions.
2015-04-01 11:09:43 +02:00
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.
2015-03-31 22:03:59 +02:00
Victor Stinner
ee699e9d2b
Issue #23618 : Fix EINTR handling in socket.connect()
...
Call PyErr_CheckSignals() if connect(), select() or getsockopt() failed with
EINTR.
2015-03-31 21:28:42 +02:00
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().
2015-03-31 21:23:10 +02:00
Victor Stinner
b6c15bcad3
Issue #23618 : Refactor internal_connect()
...
On Windows, internal_connect() now reuses internal_connect_select() and always
calls getsockopt().
2015-03-31 16:35:35 +02:00
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.
2015-03-31 16:08:22 +02:00
Victor Stinner
1bb0aef4d1
Issue #22117 : Fix integer overflow check in socket_parse_timeout() on Windows
2015-03-31 16:31:19 +02:00
Victor Stinner
dd83bd2f9c
Issue #23618 : Fix internal_connect_select()
2015-03-31 14:24:47 +02:00
Victor Stinner
416f2e66ca
Issue #23618 : internal_connect_select() now waits also for error events
2015-03-31 13:56:29 +02:00
Victor Stinner
e6951c6c8a
Issue #23618 : Refactor internal_select() to prepare socket.connect() for EINTR
2015-03-31 13:50:44 +02:00
Victor Stinner
391fa713f7
Issue #23618 : Refactor the _socket module
...
* Inline internal_select() function
* Rename internal_select_ex() internal_select()
2015-03-31 13:15:31 +02:00
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.
2015-03-30 03:49:14 +02:00
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.
2015-03-30 02:51:13 +02:00
Victor Stinner
71694d5c8c
Issue #22117 : The socket module uses _PyTime_t timestamp for timeouts
2015-03-28 01:18:54 +01:00
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.
2015-03-27 22:59:32 +01:00
Victor Stinner
f50e187724
Fix compiler warnings: comparison between signed and unsigned numbers
2015-03-20 11:32:24 +01:00
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.
2015-03-20 09:00:36 +02:00
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.
2015-03-20 01:42:20 +01:00
Serhiy Storchaka
caa01f861c
Fixed GCC version testing.
2015-03-05 23:42:24 +02:00
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.
2015-03-05 14:04:03 +01:00
Serhiy Storchaka
b48af340b9
Silenced minor GCC warnings.
2015-02-26 15:27:57 +02:00
Serhiy Storchaka
4d0d982985
Issue #23446 : Use PyMem_New instead of PyMem_Malloc to avoid possible integer
...
overflows. Added few missed PyErr_NoMemory().
2015-02-16 13:33:32 +02:00
Serhiy Storchaka
1a1ff29659
Issue #23446 : Use PyMem_New instead of PyMem_Malloc to avoid possible integer
...
overflows. Added few missed PyErr_NoMemory().
2015-02-16 13:28:22 +02:00
Charles-François Natali
6e6c59b508
Issue #23285 : PEP 475 -- Retry system calls failing with EINTR.
2015-02-07 13:27:50 +00:00
Serhiy Storchaka
b757c83ec6
Issue #22581 : Use more "bytes-like object" throughout the docs and comments.
2014-12-05 22:25:22 +02:00
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.
2014-11-22 12:54:57 -08:00
Serhiy Storchaka
92bf919ed0
Issue #22581 : Use more "bytes-like object" throughout the docs and comments.
2014-12-05 22:26:10 +02:00
Charles-François Natali
ea07eb9469
Issue #22378 : socket module: add SO_MARK.
2014-09-18 23:18:46 +01:00
Serhiy Storchaka
d8a1447c99
Issue #22215 : Now ValueError is raised instead of TypeError when str or bytes
...
argument contains not permitted null character or byte.
2014-09-06 20:07:17 +03:00
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.
2014-09-02 23:18:25 +02:00