Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 394103
Collapse All | Expand All

(-)Python-2.7.2/Modules/_multiprocessing//socket_connection.c (-13 / +31 lines)
Lines 6-11 Link Here
6
 * Copyright (c) 2006-2008, R Oudkerk --- see COPYING.txt
6
 * Copyright (c) 2006-2008, R Oudkerk --- see COPYING.txt
7
 */
7
 */
8
8
9
#ifndef MS_WINDOWS
10
#include <poll.h>
11
#endif
9
#include "multiprocessing.h"
12
#include "multiprocessing.h"
10
13
11
#ifdef MS_WINDOWS
14
#ifdef MS_WINDOWS
Lines 148-153 conn_recv_string(ConnectionObject *conn, char *buffer, Link Here
148
    }
151
    }
149
}
152
}
150
153
154
#ifdef MS_WINDOWS
151
/*
155
/*
152
 * Check whether any data is available for reading -- neg timeout blocks
156
 * Check whether any data is available for reading -- neg timeout blocks
153
 */
157
 */
Lines 158-175 conn_poll(ConnectionObject *conn, double timeout, PyThreadState *_save) Link Here
158
    int res;
162
    int res;
159
    fd_set rfds;
163
    fd_set rfds;
160
164
161
    /*
162
     * Verify the handle, issue 3321. Not required for windows.
163
     */
164
    #ifndef MS_WINDOWS
165
        if (((int)conn->handle) < 0 || ((int)conn->handle) >= FD_SETSIZE) {
166
            Py_BLOCK_THREADS
167
            PyErr_SetString(PyExc_IOError, "handle out of range in select()");
168
            Py_UNBLOCK_THREADS
169
            return MP_EXCEPTION_HAS_BEEN_SET;
170
        }
171
    #endif
172
173
    FD_ZERO(&rfds);
165
    FD_ZERO(&rfds);
174
    FD_SET((SOCKET)conn->handle, &rfds);
166
    FD_SET((SOCKET)conn->handle, &rfds);
175
167
Lines 191-196 conn_poll(ConnectionObject *conn, double timeout, PyThreadState *_save) Link Here
191
        return FALSE;
183
        return FALSE;
192
    }
184
    }
193
}
185
}
186
#else
187
/*
188
 * Check whether any data is available for reading -- neg timeout blocks
189
 */
190
191
static int
192
conn_poll(ConnectionObject *conn, double timeout, PyThreadState *_save)
193
{
194
    int res;
195
    struct pollfd p;
196
197
    p.fd = (int)conn->handle;
198
    p.events = POLLIN | POLLPRI;
199
    p.revents = 0;
200
201
    res = poll(&p, 1, (int)timeout * 1000);
202
203
    if (res < 0) {
204
        return MP_SOCKET_ERROR;
205
    } else if (p.revents & (POLLIN | POLLPRI)) {
206
        return TRUE;
207
    } else {
208
        assert(res == 0);
209
        return FALSE;
210
    }
211
}
212
#endif
194
213
195
/*
214
/*
196
 * "connection.h" defines the Connection type using defs above
215
 * "connection.h" defines the Connection type using defs above
197
- 

Return to bug 394103