diff options
author | Benjamin Peterson <benjamin@python.org> | 2009-04-05 21:24:58 (GMT) |
---|---|---|
committer | Benjamin Peterson <benjamin@python.org> | 2009-04-05 21:24:58 (GMT) |
commit | 965ce8799190b7017a41cd00eede083b342a15fb (patch) | |
tree | b903bd81fdf0c37363160a69aa0371ddac4b90c7 /Modules | |
parent | 1cdd83c2abf273cc5d5d214f064cc2125dd0f537 (diff) | |
download | cpython-965ce8799190b7017a41cd00eede083b342a15fb.zip cpython-965ce8799190b7017a41cd00eede083b342a15fb.tar.gz cpython-965ce8799190b7017a41cd00eede083b342a15fb.tar.bz2 |
Merged revisions 70908,70939,71009,71022,71036 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r70908 | jesse.noller | 2009-03-31 17:20:35 -0500 (Tue, 31 Mar 2009) | 1 line
Issue 5619: Pass MS CRT debug flags into subprocesses
........
r70939 | jesse.noller | 2009-03-31 22:45:50 -0500 (Tue, 31 Mar 2009) | 1 line
Fix multiprocessing.event to match the new threading.Event API
........
r71009 | jesse.noller | 2009-04-01 19:03:28 -0500 (Wed, 01 Apr 2009) | 1 line
issue5545: Switch to Autoconf for multiprocessing; special thanks to Martin Lowis for help
........
r71022 | jesse.noller | 2009-04-01 21:32:55 -0500 (Wed, 01 Apr 2009) | 1 line
Issue 3110: Additional protection for SEM_VALUE_MAX on platforms, thanks to Martin Loewis
........
r71036 | jesse.noller | 2009-04-01 23:22:09 -0500 (Wed, 01 Apr 2009) | 1 line
Issue 3551: Raise ValueError if the size causes ERROR_NO_SYSTEM_RESOURCES
........
Diffstat (limited to 'Modules')
-rw-r--r-- | Modules/_multiprocessing/connection.h | 8 | ||||
-rw-r--r-- | Modules/_multiprocessing/multiprocessing.c | 8 | ||||
-rw-r--r-- | Modules/_multiprocessing/multiprocessing.h | 17 | ||||
-rw-r--r-- | Modules/_multiprocessing/pipe_connection.c | 6 | ||||
-rw-r--r-- | Modules/_multiprocessing/semaphore.c | 10 |
5 files changed, 35 insertions, 14 deletions
diff --git a/Modules/_multiprocessing/connection.h b/Modules/_multiprocessing/connection.h index 581beac..2ee5368 100644 --- a/Modules/_multiprocessing/connection.h +++ b/Modules/_multiprocessing/connection.h @@ -139,8 +139,12 @@ connection_sendbytes(ConnectionObject *self, PyObject *args) res = conn_send_string(self, buffer + offset, size); PyBuffer_Release(&pbuffer); - if (res < 0) - return mp_SetError(PyExc_IOError, res); + if (res < 0) { + if (PyErr_Occurred()) + return NULL; + else + return mp_SetError(PyExc_IOError, res); + } Py_RETURN_NONE; } diff --git a/Modules/_multiprocessing/multiprocessing.c b/Modules/_multiprocessing/multiprocessing.c index b18f714..afa2599 100644 --- a/Modules/_multiprocessing/multiprocessing.c +++ b/Modules/_multiprocessing/multiprocessing.c @@ -8,6 +8,12 @@ #include "multiprocessing.h" +#ifdef SCM_RIGHTS + #define HAVE_FD_TRANSFER 1 +#else + #define HAVE_FD_TRANSFER 0 +#endif + PyObject *create_win32_namespace(void); PyObject *pickle_dumps, *pickle_loads, *pickle_protocol; @@ -257,7 +263,7 @@ PyInit__multiprocessing(void) Py_INCREF(&ConnectionType); PyModule_AddObject(module, "Connection", (PyObject*)&ConnectionType); -#if defined(MS_WINDOWS) || HAVE_SEM_OPEN +#if defined(MS_WINDOWS) || defined(HAVE_SEM_OPEN) /* Add SemLock type to module */ if (PyType_Ready(&SemLockType) < 0) return NULL; diff --git a/Modules/_multiprocessing/multiprocessing.h b/Modules/_multiprocessing/multiprocessing.h index 4f4f9d7..f8750d2 100644 --- a/Modules/_multiprocessing/multiprocessing.h +++ b/Modules/_multiprocessing/multiprocessing.h @@ -27,7 +27,7 @@ # include <sys/socket.h> # include <sys/uio.h> # include <arpa/inet.h> /* htonl() and ntohl() */ -# if HAVE_SEM_OPEN +# ifdef HAVE_SEM_OPEN # include <semaphore.h> typedef sem_t *SEM_HANDLE; # endif @@ -45,13 +45,18 @@ * Issue 3110 - Solaris does not define SEM_VALUE_MAX */ #ifndef SEM_VALUE_MAX -# ifdef _SEM_VALUE_MAX -# define SEM_VALUE_MAX _SEM_VALUE_MAX -# else -# define SEM_VALUE_MAX INT_MAX -# endif + #if defined(HAVE_SYSCONF) && defined(_SC_SEM_VALUE_MAX) + # define SEM_VALUE_MAX sysconf(_SC_SEM_VALUE_MAX) + #elif defined(_SEM_VALUE_MAX) + # define SEM_VALUE_MAX _SEM_VALUE_MAX + #elif definef(_POSIX_SEM_VALUE_MAX) + # define SEM_VALUE_MAX _POSIX_SEM_VALUE_MAX + #else + # define SEM_VALUE_MAX INT_MAX + #endif #endif + /* * Make sure Py_ssize_t available */ diff --git a/Modules/_multiprocessing/pipe_connection.c b/Modules/_multiprocessing/pipe_connection.c index 27e79dd..66947c8 100644 --- a/Modules/_multiprocessing/pipe_connection.c +++ b/Modules/_multiprocessing/pipe_connection.c @@ -23,6 +23,12 @@ conn_send_string(ConnectionObject *conn, char *string, size_t length) Py_BEGIN_ALLOW_THREADS ret = WriteFile(conn->handle, string, length, &amount_written, NULL); Py_END_ALLOW_THREADS + + if (ret == 0 && GetLastError() == ERROR_NO_SYSTEM_RESOURCES) { + PyErr_Format(PyExc_ValueError, "Cannnot send %" PY_FORMAT_SIZE_T "d bytes over connection", length); + return MP_STANDARD_ERROR; + } + return ret ? MP_SUCCESS : MP_STANDARD_ERROR; } diff --git a/Modules/_multiprocessing/semaphore.c b/Modules/_multiprocessing/semaphore.c index 40bd7c3..c0944c9 100644 --- a/Modules/_multiprocessing/semaphore.c +++ b/Modules/_multiprocessing/semaphore.c @@ -197,11 +197,11 @@ semlock_release(SemLockObject *self, PyObject *args) #define SEM_GETVALUE(sem, pval) sem_getvalue(sem, pval) #define SEM_UNLINK(name) sem_unlink(name) -#if HAVE_BROKEN_SEM_UNLINK +#ifndef HAVE_SEM_UNLINK # define sem_unlink(name) 0 #endif -#if !HAVE_SEM_TIMEDWAIT +#ifndef HAVE_SEM_TIMEDWAIT # define sem_timedwait(sem,deadline) sem_timedwait_save(sem,deadline,_save) int @@ -348,7 +348,7 @@ semlock_release(SemLockObject *self, PyObject *args) } assert(self->count == 1); } else { -#if HAVE_BROKEN_SEM_GETVALUE +#ifdef HAVE_BROKEN_SEM_GETVALUE /* We will only check properly the maxvalue == 1 case */ if (self->maxvalue == 1) { /* make sure that already locked */ @@ -494,7 +494,7 @@ semlock_ismine(SemLockObject *self) static PyObject * semlock_getvalue(SemLockObject *self) { -#if HAVE_BROKEN_SEM_GETVALUE +#ifdef HAVE_BROKEN_SEM_GETVALUE PyErr_SetNone(PyExc_NotImplementedError); return NULL; #else @@ -512,7 +512,7 @@ semlock_getvalue(SemLockObject *self) static PyObject * semlock_iszero(SemLockObject *self) { -#if HAVE_BROKEN_SEM_GETVALUE +#ifdef HAVE_BROKEN_SEM_GETVALUE if (sem_trywait(self->handle) < 0) { if (errno == EAGAIN) Py_RETURN_TRUE; |