--- Python-2.7.2/Modules/_multiprocessing//socket_connection.c 2010-05-09 17:52:27.000000000 +0200 +++ Python-2.7.2/Modules/_multiprocessing//socket_connection.c 2010-11-25 12:11:34.412378003 +0100 @@ -6,6 +6,9 @@ * Copyright (c) 2006-2008, R Oudkerk --- see COPYING.txt */ +#ifndef MS_WINDOWS +#include +#endif #include "multiprocessing.h" #ifdef MS_WINDOWS @@ -148,6 +151,7 @@ conn_recv_string(ConnectionObject *conn, char *buffer, } } +#ifdef MS_WINDOWS /* * Check whether any data is available for reading -- neg timeout blocks */ @@ -158,18 +162,6 @@ conn_poll(ConnectionObject *conn, double timeout, PyThreadState *_save) int res; fd_set rfds; - /* - * Verify the handle, issue 3321. Not required for windows. - */ - #ifndef MS_WINDOWS - if (((int)conn->handle) < 0 || ((int)conn->handle) >= FD_SETSIZE) { - Py_BLOCK_THREADS - PyErr_SetString(PyExc_IOError, "handle out of range in select()"); - Py_UNBLOCK_THREADS - return MP_EXCEPTION_HAS_BEEN_SET; - } - #endif - FD_ZERO(&rfds); FD_SET((SOCKET)conn->handle, &rfds); @@ -191,6 +183,33 @@ conn_poll(ConnectionObject *conn, double timeout, PyThreadState *_save) return FALSE; } } +#else +/* + * Check whether any data is available for reading -- neg timeout blocks + */ + +static int +conn_poll(ConnectionObject *conn, double timeout, PyThreadState *_save) +{ + int res; + struct pollfd p; + + p.fd = (int)conn->handle; + p.events = POLLIN | POLLPRI; + p.revents = 0; + + res = poll(&p, 1, (int)timeout * 1000); + + if (res < 0) { + return MP_SOCKET_ERROR; + } else if (p.revents & (POLLIN | POLLPRI)) { + return TRUE; + } else { + assert(res == 0); + return FALSE; + } +} +#endif /* * "connection.h" defines the Connection type using defs above --