Guido van Rossum | 4f0fbf8 | 1996-06-12 04:22:53 +0000 | [diff] [blame] | 1 | /* select - Module containing unix select(2) call. |
Barry Warsaw | e4ac0aa | 1996-12-12 00:04:35 +0000 | [diff] [blame] | 2 | Under Unix, the file descriptors are small integers. |
| 3 | Under Win32, select only exists for sockets, and sockets may |
| 4 | have any value except INVALID_SOCKET. |
Guido van Rossum | bcc2074 | 1998-08-04 22:53:56 +0000 | [diff] [blame] | 5 | Under BeOS, we suffer the same dichotomy as Win32; sockets can be anything |
| 6 | >= 0. |
Guido van Rossum | 4f0fbf8 | 1996-06-12 04:22:53 +0000 | [diff] [blame] | 7 | */ |
Guido van Rossum | ed233a5 | 1992-06-23 09:07:03 +0000 | [diff] [blame] | 8 | |
Barry Warsaw | e4ac0aa | 1996-12-12 00:04:35 +0000 | [diff] [blame] | 9 | #include "Python.h" |
Guido van Rossum | ed233a5 | 1992-06-23 09:07:03 +0000 | [diff] [blame] | 10 | |
Tim Peters | d92dfe0 | 2000-12-12 01:18:41 +0000 | [diff] [blame] | 11 | /* Windows #defines FD_SETSIZE to 64 if FD_SETSIZE isn't already defined. |
| 12 | 64 is too small (too many people have bumped into that limit). |
| 13 | Here we boost it. |
| 14 | Users who want even more than the boosted limit should #define |
| 15 | FD_SETSIZE higher before this; e.g., via compiler /D switch. |
| 16 | */ |
| 17 | #if defined(MS_WINDOWS) && !defined(FD_SETSIZE) |
| 18 | #define FD_SETSIZE 512 |
| 19 | #endif |
| 20 | |
Guido van Rossum | a376cc5 | 1996-12-05 23:43:35 +0000 | [diff] [blame] | 21 | #ifdef HAVE_UNISTD_H |
| 22 | #include <unistd.h> |
| 23 | #endif |
Andrew M. Kuchling | 737fbb3 | 2001-07-14 20:54:37 +0000 | [diff] [blame] | 24 | #if defined(HAVE_POLL_H) |
Andrew M. Kuchling | cf96dc8 | 2000-08-25 01:15:33 +0000 | [diff] [blame] | 25 | #include <poll.h> |
Andrew M. Kuchling | 737fbb3 | 2001-07-14 20:54:37 +0000 | [diff] [blame] | 26 | #elif defined(HAVE_SYS_POLL_H) |
| 27 | #include <sys/poll.h> |
Andrew M. Kuchling | cf96dc8 | 2000-08-25 01:15:33 +0000 | [diff] [blame] | 28 | #endif |
Guido van Rossum | a376cc5 | 1996-12-05 23:43:35 +0000 | [diff] [blame] | 29 | |
Guido van Rossum | 3727317 | 1996-12-09 18:47:43 +0000 | [diff] [blame] | 30 | #ifdef __sgi |
| 31 | /* This is missing from unistd.h */ |
Thomas Wouters | bd4bc4e | 2000-07-22 23:57:55 +0000 | [diff] [blame] | 32 | extern void bzero(void *, int); |
Guido van Rossum | 3727317 | 1996-12-09 18:47:43 +0000 | [diff] [blame] | 33 | #endif |
| 34 | |
Guido van Rossum | ff7e83d | 1999-08-27 20:39:37 +0000 | [diff] [blame] | 35 | #ifndef DONT_HAVE_SYS_TYPES_H |
Guido van Rossum | b6775db | 1994-08-01 11:34:53 +0000 | [diff] [blame] | 36 | #include <sys/types.h> |
Guido van Rossum | ff7e83d | 1999-08-27 20:39:37 +0000 | [diff] [blame] | 37 | #endif |
Guido van Rossum | 4f0fbf8 | 1996-06-12 04:22:53 +0000 | [diff] [blame] | 38 | |
Guido van Rossum | 8e9ebfd | 1997-11-22 21:53:48 +0000 | [diff] [blame] | 39 | #if defined(PYOS_OS2) |
| 40 | #include <sys/time.h> |
| 41 | #include <utils.h> |
| 42 | #endif |
| 43 | |
Guido van Rossum | 6f489d9 | 1996-06-28 20:15:15 +0000 | [diff] [blame] | 44 | #ifdef MS_WINDOWS |
Guido van Rossum | 4f0fbf8 | 1996-06-12 04:22:53 +0000 | [diff] [blame] | 45 | #include <winsock.h> |
| 46 | #else |
Guido van Rossum | bcc2074 | 1998-08-04 22:53:56 +0000 | [diff] [blame] | 47 | #ifdef __BEOS__ |
| 48 | #include <net/socket.h> |
| 49 | #define SOCKET int |
| 50 | #else |
Guido van Rossum | 4f0fbf8 | 1996-06-12 04:22:53 +0000 | [diff] [blame] | 51 | #define SOCKET int |
| 52 | #endif |
Guido van Rossum | bcc2074 | 1998-08-04 22:53:56 +0000 | [diff] [blame] | 53 | #endif |
Guido van Rossum | ed233a5 | 1992-06-23 09:07:03 +0000 | [diff] [blame] | 54 | |
Guido van Rossum | 1ca8bb3 | 2001-03-02 06:28:17 +0000 | [diff] [blame] | 55 | #ifdef RISCOS |
| 56 | #define NO_DUP |
| 57 | #undef off_t |
| 58 | #undef uid_t |
| 59 | #undef gid_t |
| 60 | #undef errno |
| 61 | #include "socklib.h" |
| 62 | #endif /* RISCOS */ |
| 63 | |
Barry Warsaw | e4ac0aa | 1996-12-12 00:04:35 +0000 | [diff] [blame] | 64 | static PyObject *SelectError; |
Guido van Rossum | ed233a5 | 1992-06-23 09:07:03 +0000 | [diff] [blame] | 65 | |
Barry Warsaw | c1cb360 | 1996-12-12 22:16:21 +0000 | [diff] [blame] | 66 | /* list of Python objects and their file descriptor */ |
| 67 | typedef struct { |
| 68 | PyObject *obj; /* owned reference */ |
Guido van Rossum | 4f0fbf8 | 1996-06-12 04:22:53 +0000 | [diff] [blame] | 69 | SOCKET fd; |
Barry Warsaw | c1cb360 | 1996-12-12 22:16:21 +0000 | [diff] [blame] | 70 | int sentinel; /* -1 == sentinel */ |
Guido van Rossum | 4f0fbf8 | 1996-06-12 04:22:53 +0000 | [diff] [blame] | 71 | } pylist; |
| 72 | |
Barry Warsaw | c1cb360 | 1996-12-12 22:16:21 +0000 | [diff] [blame] | 73 | static void |
Peter Schneider-Kamp | 41c36ff | 2000-07-10 12:29:26 +0000 | [diff] [blame] | 74 | reap_obj(pylist fd2obj[FD_SETSIZE + 3]) |
Barry Warsaw | c1cb360 | 1996-12-12 22:16:21 +0000 | [diff] [blame] | 75 | { |
| 76 | int i; |
| 77 | for (i = 0; i < FD_SETSIZE + 3 && fd2obj[i].sentinel >= 0; i++) { |
| 78 | Py_XDECREF(fd2obj[i].obj); |
| 79 | fd2obj[i].obj = NULL; |
| 80 | } |
| 81 | fd2obj[0].sentinel = -1; |
| 82 | } |
| 83 | |
| 84 | |
Barry Warsaw | e4ac0aa | 1996-12-12 00:04:35 +0000 | [diff] [blame] | 85 | /* returns -1 and sets the Python exception if an error occurred, otherwise |
| 86 | returns a number >= 0 |
| 87 | */ |
Guido van Rossum | 4f0fbf8 | 1996-06-12 04:22:53 +0000 | [diff] [blame] | 88 | static int |
Peter Schneider-Kamp | 41c36ff | 2000-07-10 12:29:26 +0000 | [diff] [blame] | 89 | list2set(PyObject *list, fd_set *set, pylist fd2obj[FD_SETSIZE + 3]) |
Guido van Rossum | ed233a5 | 1992-06-23 09:07:03 +0000 | [diff] [blame] | 90 | { |
Barry Warsaw | c1cb360 | 1996-12-12 22:16:21 +0000 | [diff] [blame] | 91 | int i; |
| 92 | int max = -1; |
| 93 | int index = 0; |
| 94 | int len = PyList_Size(list); |
| 95 | PyObject* o = NULL; |
Guido van Rossum | 07432c0 | 1995-03-29 16:47:45 +0000 | [diff] [blame] | 96 | |
Barry Warsaw | e4ac0aa | 1996-12-12 00:04:35 +0000 | [diff] [blame] | 97 | fd2obj[0].obj = (PyObject*)0; /* set list to zero size */ |
Barry Warsaw | e4ac0aa | 1996-12-12 00:04:35 +0000 | [diff] [blame] | 98 | FD_ZERO(set); |
Barry Warsaw | c1cb360 | 1996-12-12 22:16:21 +0000 | [diff] [blame] | 99 | |
| 100 | for (i = 0; i < len; i++) { |
Barry Warsaw | c1cb360 | 1996-12-12 22:16:21 +0000 | [diff] [blame] | 101 | SOCKET v; |
| 102 | |
| 103 | /* any intervening fileno() calls could decr this refcnt */ |
Barry Warsaw | 24c4b3d | 1996-12-13 23:22:42 +0000 | [diff] [blame] | 104 | if (!(o = PyList_GetItem(list, i))) |
Barry Warsaw | 529fcfe | 1996-12-16 18:15:34 +0000 | [diff] [blame] | 105 | return -1; |
Barry Warsaw | 24c4b3d | 1996-12-13 23:22:42 +0000 | [diff] [blame] | 106 | |
Barry Warsaw | c1cb360 | 1996-12-12 22:16:21 +0000 | [diff] [blame] | 107 | Py_INCREF(o); |
Andrew M. Kuchling | 9f28a03 | 2000-07-13 23:59:35 +0000 | [diff] [blame] | 108 | v = PyObject_AsFileDescriptor( o ); |
| 109 | if (v == -1) goto finally; |
Barry Warsaw | c1cb360 | 1996-12-12 22:16:21 +0000 | [diff] [blame] | 110 | |
Guido van Rossum | 947a0fa | 2000-01-14 16:33:09 +0000 | [diff] [blame] | 111 | #if defined(_MSC_VER) |
Barry Warsaw | c1cb360 | 1996-12-12 22:16:21 +0000 | [diff] [blame] | 112 | max = 0; /* not used for Win32 */ |
| 113 | #else /* !_MSC_VER */ |
Barry Warsaw | e4ac0aa | 1996-12-12 00:04:35 +0000 | [diff] [blame] | 114 | if (v < 0 || v >= FD_SETSIZE) { |
Barry Warsaw | c1cb360 | 1996-12-12 22:16:21 +0000 | [diff] [blame] | 115 | PyErr_SetString(PyExc_ValueError, |
| 116 | "filedescriptor out of range in select()"); |
| 117 | goto finally; |
Barry Warsaw | e4ac0aa | 1996-12-12 00:04:35 +0000 | [diff] [blame] | 118 | } |
| 119 | if (v > max) |
| 120 | max = v; |
Barry Warsaw | c1cb360 | 1996-12-12 22:16:21 +0000 | [diff] [blame] | 121 | #endif /* _MSC_VER */ |
Barry Warsaw | e4ac0aa | 1996-12-12 00:04:35 +0000 | [diff] [blame] | 122 | FD_SET(v, set); |
Barry Warsaw | c1cb360 | 1996-12-12 22:16:21 +0000 | [diff] [blame] | 123 | |
Barry Warsaw | e4ac0aa | 1996-12-12 00:04:35 +0000 | [diff] [blame] | 124 | /* add object and its file descriptor to the list */ |
| 125 | if (index >= FD_SETSIZE) { |
Barry Warsaw | c1cb360 | 1996-12-12 22:16:21 +0000 | [diff] [blame] | 126 | PyErr_SetString(PyExc_ValueError, |
| 127 | "too many file descriptors in select()"); |
| 128 | goto finally; |
Barry Warsaw | e4ac0aa | 1996-12-12 00:04:35 +0000 | [diff] [blame] | 129 | } |
| 130 | fd2obj[index].obj = o; |
| 131 | fd2obj[index].fd = v; |
Barry Warsaw | c1cb360 | 1996-12-12 22:16:21 +0000 | [diff] [blame] | 132 | fd2obj[index].sentinel = 0; |
| 133 | fd2obj[++index].sentinel = -1; |
Guido van Rossum | 4f0fbf8 | 1996-06-12 04:22:53 +0000 | [diff] [blame] | 134 | } |
Barry Warsaw | e4ac0aa | 1996-12-12 00:04:35 +0000 | [diff] [blame] | 135 | return max+1; |
Barry Warsaw | c1cb360 | 1996-12-12 22:16:21 +0000 | [diff] [blame] | 136 | |
| 137 | finally: |
| 138 | Py_XDECREF(o); |
| 139 | return -1; |
Guido van Rossum | ed233a5 | 1992-06-23 09:07:03 +0000 | [diff] [blame] | 140 | } |
| 141 | |
Barry Warsaw | e4ac0aa | 1996-12-12 00:04:35 +0000 | [diff] [blame] | 142 | /* returns NULL and sets the Python exception if an error occurred */ |
| 143 | static PyObject * |
Peter Schneider-Kamp | 41c36ff | 2000-07-10 12:29:26 +0000 | [diff] [blame] | 144 | set2list(fd_set *set, pylist fd2obj[FD_SETSIZE + 3]) |
Guido van Rossum | ed233a5 | 1992-06-23 09:07:03 +0000 | [diff] [blame] | 145 | { |
Barry Warsaw | c1cb360 | 1996-12-12 22:16:21 +0000 | [diff] [blame] | 146 | int i, j, count=0; |
Barry Warsaw | e4ac0aa | 1996-12-12 00:04:35 +0000 | [diff] [blame] | 147 | PyObject *list, *o; |
| 148 | SOCKET fd; |
Guido van Rossum | ed233a5 | 1992-06-23 09:07:03 +0000 | [diff] [blame] | 149 | |
Barry Warsaw | c1cb360 | 1996-12-12 22:16:21 +0000 | [diff] [blame] | 150 | for (j = 0; fd2obj[j].sentinel >= 0; j++) { |
Barry Warsaw | e4ac0aa | 1996-12-12 00:04:35 +0000 | [diff] [blame] | 151 | if (FD_ISSET(fd2obj[j].fd, set)) |
Barry Warsaw | c1cb360 | 1996-12-12 22:16:21 +0000 | [diff] [blame] | 152 | count++; |
| 153 | } |
| 154 | list = PyList_New(count); |
Barry Warsaw | e4ac0aa | 1996-12-12 00:04:35 +0000 | [diff] [blame] | 155 | if (!list) |
| 156 | return NULL; |
| 157 | |
Barry Warsaw | c1cb360 | 1996-12-12 22:16:21 +0000 | [diff] [blame] | 158 | i = 0; |
| 159 | for (j = 0; fd2obj[j].sentinel >= 0; j++) { |
Barry Warsaw | e4ac0aa | 1996-12-12 00:04:35 +0000 | [diff] [blame] | 160 | fd = fd2obj[j].fd; |
| 161 | if (FD_ISSET(fd, set)) { |
Guido van Rossum | 4f0fbf8 | 1996-06-12 04:22:53 +0000 | [diff] [blame] | 162 | #ifndef _MSC_VER |
Barry Warsaw | e4ac0aa | 1996-12-12 00:04:35 +0000 | [diff] [blame] | 163 | if (fd > FD_SETSIZE) { |
| 164 | PyErr_SetString(PyExc_SystemError, |
| 165 | "filedescriptor out of range returned in select()"); |
Barry Warsaw | c1cb360 | 1996-12-12 22:16:21 +0000 | [diff] [blame] | 166 | goto finally; |
Barry Warsaw | e4ac0aa | 1996-12-12 00:04:35 +0000 | [diff] [blame] | 167 | } |
Guido van Rossum | 4f0fbf8 | 1996-06-12 04:22:53 +0000 | [diff] [blame] | 168 | #endif |
Barry Warsaw | e4ac0aa | 1996-12-12 00:04:35 +0000 | [diff] [blame] | 169 | o = fd2obj[j].obj; |
Barry Warsaw | c1cb360 | 1996-12-12 22:16:21 +0000 | [diff] [blame] | 170 | fd2obj[j].obj = NULL; |
| 171 | /* transfer ownership */ |
| 172 | if (PyList_SetItem(list, i, o) < 0) |
| 173 | goto finally; |
| 174 | |
| 175 | i++; |
Barry Warsaw | e4ac0aa | 1996-12-12 00:04:35 +0000 | [diff] [blame] | 176 | } |
| 177 | } |
| 178 | return list; |
Barry Warsaw | c1cb360 | 1996-12-12 22:16:21 +0000 | [diff] [blame] | 179 | finally: |
| 180 | Py_DECREF(list); |
| 181 | return NULL; |
Guido van Rossum | ed233a5 | 1992-06-23 09:07:03 +0000 | [diff] [blame] | 182 | } |
Barry Warsaw | c1cb360 | 1996-12-12 22:16:21 +0000 | [diff] [blame] | 183 | |
Guido van Rossum | ed233a5 | 1992-06-23 09:07:03 +0000 | [diff] [blame] | 184 | |
Barry Warsaw | e4ac0aa | 1996-12-12 00:04:35 +0000 | [diff] [blame] | 185 | static PyObject * |
Peter Schneider-Kamp | 41c36ff | 2000-07-10 12:29:26 +0000 | [diff] [blame] | 186 | select_select(PyObject *self, PyObject *args) |
Guido van Rossum | ed233a5 | 1992-06-23 09:07:03 +0000 | [diff] [blame] | 187 | { |
Guido van Rossum | d20781b | 1998-07-02 02:53:36 +0000 | [diff] [blame] | 188 | #ifdef MS_WINDOWS |
| 189 | /* This would be an awful lot of stack space on Windows! */ |
| 190 | pylist *rfd2obj, *wfd2obj, *efd2obj; |
| 191 | #else |
Barry Warsaw | e4ac0aa | 1996-12-12 00:04:35 +0000 | [diff] [blame] | 192 | pylist rfd2obj[FD_SETSIZE + 3]; |
| 193 | pylist wfd2obj[FD_SETSIZE + 3]; |
| 194 | pylist efd2obj[FD_SETSIZE + 3]; |
Guido van Rossum | d20781b | 1998-07-02 02:53:36 +0000 | [diff] [blame] | 195 | #endif |
Barry Warsaw | e4ac0aa | 1996-12-12 00:04:35 +0000 | [diff] [blame] | 196 | PyObject *ifdlist, *ofdlist, *efdlist; |
Barry Warsaw | c1cb360 | 1996-12-12 22:16:21 +0000 | [diff] [blame] | 197 | PyObject *ret = NULL; |
Barry Warsaw | e4ac0aa | 1996-12-12 00:04:35 +0000 | [diff] [blame] | 198 | PyObject *tout = Py_None; |
| 199 | fd_set ifdset, ofdset, efdset; |
| 200 | double timeout; |
| 201 | struct timeval tv, *tvp; |
Guido van Rossum | 3262e16 | 2000-06-28 21:18:13 +0000 | [diff] [blame] | 202 | long seconds; |
Barry Warsaw | e4ac0aa | 1996-12-12 00:04:35 +0000 | [diff] [blame] | 203 | int imax, omax, emax, max; |
| 204 | int n; |
Guido van Rossum | ed233a5 | 1992-06-23 09:07:03 +0000 | [diff] [blame] | 205 | |
Barry Warsaw | e4ac0aa | 1996-12-12 00:04:35 +0000 | [diff] [blame] | 206 | /* convert arguments */ |
Guido van Rossum | 43713e5 | 2000-02-29 13:59:29 +0000 | [diff] [blame] | 207 | if (!PyArg_ParseTuple(args, "OOO|O:select", |
Barry Warsaw | e4ac0aa | 1996-12-12 00:04:35 +0000 | [diff] [blame] | 208 | &ifdlist, &ofdlist, &efdlist, &tout)) |
| 209 | return NULL; |
Guido van Rossum | ed233a5 | 1992-06-23 09:07:03 +0000 | [diff] [blame] | 210 | |
Barry Warsaw | e4ac0aa | 1996-12-12 00:04:35 +0000 | [diff] [blame] | 211 | if (tout == Py_None) |
| 212 | tvp = (struct timeval *)0; |
Barry Warsaw | c1cb360 | 1996-12-12 22:16:21 +0000 | [diff] [blame] | 213 | else if (!PyArg_Parse(tout, "d", &timeout)) { |
| 214 | PyErr_SetString(PyExc_TypeError, |
| 215 | "timeout must be a float or None"); |
Barry Warsaw | e4ac0aa | 1996-12-12 00:04:35 +0000 | [diff] [blame] | 216 | return NULL; |
Barry Warsaw | c1cb360 | 1996-12-12 22:16:21 +0000 | [diff] [blame] | 217 | } |
Guido van Rossum | c7a2270 | 1993-11-01 16:27:16 +0000 | [diff] [blame] | 218 | else { |
Guido van Rossum | 3262e16 | 2000-06-28 21:18:13 +0000 | [diff] [blame] | 219 | if (timeout > (double)LONG_MAX) { |
| 220 | PyErr_SetString(PyExc_OverflowError, "timeout period too long"); |
| 221 | return NULL; |
| 222 | } |
| 223 | seconds = (long)timeout; |
Barry Warsaw | e4ac0aa | 1996-12-12 00:04:35 +0000 | [diff] [blame] | 224 | timeout = timeout - (double)seconds; |
| 225 | tv.tv_sec = seconds; |
Guido van Rossum | 3262e16 | 2000-06-28 21:18:13 +0000 | [diff] [blame] | 226 | tv.tv_usec = (long)(timeout*1000000.0); |
Barry Warsaw | e4ac0aa | 1996-12-12 00:04:35 +0000 | [diff] [blame] | 227 | tvp = &tv; |
Guido van Rossum | c7a2270 | 1993-11-01 16:27:16 +0000 | [diff] [blame] | 228 | } |
Guido van Rossum | ed233a5 | 1992-06-23 09:07:03 +0000 | [diff] [blame] | 229 | |
Barry Warsaw | e4ac0aa | 1996-12-12 00:04:35 +0000 | [diff] [blame] | 230 | /* sanity check first three arguments */ |
| 231 | if (!PyList_Check(ifdlist) || |
| 232 | !PyList_Check(ofdlist) || |
| 233 | !PyList_Check(efdlist)) |
| 234 | { |
| 235 | PyErr_SetString(PyExc_TypeError, |
| 236 | "arguments 1-3 must be lists"); |
| 237 | return NULL; |
| 238 | } |
Guido van Rossum | ed233a5 | 1992-06-23 09:07:03 +0000 | [diff] [blame] | 239 | |
Guido van Rossum | d20781b | 1998-07-02 02:53:36 +0000 | [diff] [blame] | 240 | #ifdef MS_WINDOWS |
| 241 | /* Allocate memory for the lists */ |
| 242 | rfd2obj = PyMem_NEW(pylist, FD_SETSIZE + 3); |
| 243 | wfd2obj = PyMem_NEW(pylist, FD_SETSIZE + 3); |
| 244 | efd2obj = PyMem_NEW(pylist, FD_SETSIZE + 3); |
| 245 | if (rfd2obj == NULL || wfd2obj == NULL || efd2obj == NULL) { |
Guido van Rossum | b18618d | 2000-05-03 23:44:39 +0000 | [diff] [blame] | 246 | if (rfd2obj) PyMem_DEL(rfd2obj); |
| 247 | if (wfd2obj) PyMem_DEL(wfd2obj); |
| 248 | if (efd2obj) PyMem_DEL(efd2obj); |
Guido van Rossum | d20781b | 1998-07-02 02:53:36 +0000 | [diff] [blame] | 249 | return NULL; |
| 250 | } |
| 251 | #endif |
Barry Warsaw | e4ac0aa | 1996-12-12 00:04:35 +0000 | [diff] [blame] | 252 | /* Convert lists to fd_sets, and get maximum fd number |
| 253 | * propagates the Python exception set in list2set() |
| 254 | */ |
Barry Warsaw | c1cb360 | 1996-12-12 22:16:21 +0000 | [diff] [blame] | 255 | rfd2obj[0].sentinel = -1; |
| 256 | wfd2obj[0].sentinel = -1; |
| 257 | efd2obj[0].sentinel = -1; |
Barry Warsaw | e4ac0aa | 1996-12-12 00:04:35 +0000 | [diff] [blame] | 258 | if ((imax=list2set(ifdlist, &ifdset, rfd2obj)) < 0) |
Barry Warsaw | c1cb360 | 1996-12-12 22:16:21 +0000 | [diff] [blame] | 259 | goto finally; |
Barry Warsaw | e4ac0aa | 1996-12-12 00:04:35 +0000 | [diff] [blame] | 260 | if ((omax=list2set(ofdlist, &ofdset, wfd2obj)) < 0) |
Barry Warsaw | c1cb360 | 1996-12-12 22:16:21 +0000 | [diff] [blame] | 261 | goto finally; |
Barry Warsaw | e4ac0aa | 1996-12-12 00:04:35 +0000 | [diff] [blame] | 262 | if ((emax=list2set(efdlist, &efdset, efd2obj)) < 0) |
Barry Warsaw | c1cb360 | 1996-12-12 22:16:21 +0000 | [diff] [blame] | 263 | goto finally; |
Barry Warsaw | e4ac0aa | 1996-12-12 00:04:35 +0000 | [diff] [blame] | 264 | max = imax; |
| 265 | if (omax > max) max = omax; |
| 266 | if (emax > max) max = emax; |
Guido van Rossum | ed233a5 | 1992-06-23 09:07:03 +0000 | [diff] [blame] | 267 | |
Barry Warsaw | e4ac0aa | 1996-12-12 00:04:35 +0000 | [diff] [blame] | 268 | Py_BEGIN_ALLOW_THREADS |
| 269 | n = select(max, &ifdset, &ofdset, &efdset, tvp); |
| 270 | Py_END_ALLOW_THREADS |
Guido van Rossum | ed233a5 | 1992-06-23 09:07:03 +0000 | [diff] [blame] | 271 | |
Barry Warsaw | e4ac0aa | 1996-12-12 00:04:35 +0000 | [diff] [blame] | 272 | if (n < 0) { |
| 273 | PyErr_SetFromErrno(SelectError); |
Barry Warsaw | e4ac0aa | 1996-12-12 00:04:35 +0000 | [diff] [blame] | 274 | } |
Barry Warsaw | c1cb360 | 1996-12-12 22:16:21 +0000 | [diff] [blame] | 275 | else if (n == 0) { |
| 276 | /* optimization */ |
Barry Warsaw | e4ac0aa | 1996-12-12 00:04:35 +0000 | [diff] [blame] | 277 | ifdlist = PyList_New(0); |
Barry Warsaw | c1cb360 | 1996-12-12 22:16:21 +0000 | [diff] [blame] | 278 | if (ifdlist) { |
| 279 | ret = Py_BuildValue("OOO", ifdlist, ifdlist, ifdlist); |
| 280 | Py_DECREF(ifdlist); |
| 281 | } |
Barry Warsaw | e4ac0aa | 1996-12-12 00:04:35 +0000 | [diff] [blame] | 282 | } |
Barry Warsaw | c1cb360 | 1996-12-12 22:16:21 +0000 | [diff] [blame] | 283 | else { |
| 284 | /* any of these three calls can raise an exception. it's more |
| 285 | convenient to test for this after all three calls... but |
| 286 | is that acceptable? |
| 287 | */ |
| 288 | ifdlist = set2list(&ifdset, rfd2obj); |
| 289 | ofdlist = set2list(&ofdset, wfd2obj); |
| 290 | efdlist = set2list(&efdset, efd2obj); |
| 291 | if (PyErr_Occurred()) |
| 292 | ret = NULL; |
| 293 | else |
| 294 | ret = Py_BuildValue("OOO", ifdlist, ofdlist, efdlist); |
Barry Warsaw | e4ac0aa | 1996-12-12 00:04:35 +0000 | [diff] [blame] | 295 | |
Barry Warsaw | c1cb360 | 1996-12-12 22:16:21 +0000 | [diff] [blame] | 296 | Py_DECREF(ifdlist); |
| 297 | Py_DECREF(ofdlist); |
| 298 | Py_DECREF(efdlist); |
| 299 | } |
| 300 | |
| 301 | finally: |
| 302 | reap_obj(rfd2obj); |
| 303 | reap_obj(wfd2obj); |
| 304 | reap_obj(efd2obj); |
Guido van Rossum | d20781b | 1998-07-02 02:53:36 +0000 | [diff] [blame] | 305 | #ifdef MS_WINDOWS |
| 306 | PyMem_DEL(rfd2obj); |
| 307 | PyMem_DEL(wfd2obj); |
| 308 | PyMem_DEL(efd2obj); |
| 309 | #endif |
Barry Warsaw | e4ac0aa | 1996-12-12 00:04:35 +0000 | [diff] [blame] | 310 | return ret; |
Guido van Rossum | ed233a5 | 1992-06-23 09:07:03 +0000 | [diff] [blame] | 311 | } |
| 312 | |
Andrew M. Kuchling | cf96dc8 | 2000-08-25 01:15:33 +0000 | [diff] [blame] | 313 | #ifdef HAVE_POLL |
| 314 | /* |
| 315 | * poll() support |
| 316 | */ |
| 317 | |
| 318 | typedef struct { |
| 319 | PyObject_HEAD |
| 320 | PyObject *dict; |
| 321 | int ufd_uptodate; |
| 322 | int ufd_len; |
| 323 | struct pollfd *ufds; |
| 324 | } pollObject; |
| 325 | |
| 326 | staticforward PyTypeObject poll_Type; |
| 327 | |
| 328 | /* Update the malloc'ed array of pollfds to match the dictionary |
| 329 | contained within a pollObject. Return 1 on success, 0 on an error. |
| 330 | */ |
| 331 | |
| 332 | static int |
| 333 | update_ufd_array(pollObject *self) |
| 334 | { |
Fred Drake | dff3a37 | 2001-07-19 21:29:49 +0000 | [diff] [blame^] | 335 | int i, pos; |
Andrew M. Kuchling | cf96dc8 | 2000-08-25 01:15:33 +0000 | [diff] [blame] | 336 | PyObject *key, *value; |
| 337 | |
| 338 | self->ufd_len = PyDict_Size(self->dict); |
| 339 | PyMem_Resize(self->ufds, struct pollfd, self->ufd_len); |
| 340 | if (self->ufds == NULL) { |
| 341 | PyErr_NoMemory(); |
| 342 | return 0; |
| 343 | } |
| 344 | |
| 345 | i = pos = 0; |
Fred Drake | dff3a37 | 2001-07-19 21:29:49 +0000 | [diff] [blame^] | 346 | while (PyDict_Next(self->dict, &pos, &key, &value)) { |
Andrew M. Kuchling | cf96dc8 | 2000-08-25 01:15:33 +0000 | [diff] [blame] | 347 | self->ufds[i].fd = PyInt_AsLong(key); |
Fred Drake | dff3a37 | 2001-07-19 21:29:49 +0000 | [diff] [blame^] | 348 | self->ufds[i].events = (short)PyInt_AsLong(value); |
Andrew M. Kuchling | cf96dc8 | 2000-08-25 01:15:33 +0000 | [diff] [blame] | 349 | i++; |
| 350 | } |
| 351 | self->ufd_uptodate = 1; |
| 352 | return 1; |
| 353 | } |
| 354 | |
| 355 | static char poll_register_doc[] = |
| 356 | "register(fd [, eventmask] ) -> None\n\n\ |
| 357 | Register a file descriptor with the polling object.\n\ |
| 358 | fd -- either an integer, or an object with a fileno() method returning an int.\n\ |
| 359 | events -- an optional bitmask describing the type of events to check for"; |
| 360 | |
| 361 | static PyObject * |
| 362 | poll_register(pollObject *self, PyObject *args) |
| 363 | { |
| 364 | PyObject *o, *key, *value; |
| 365 | int fd, events = POLLIN | POLLPRI | POLLOUT; |
| 366 | |
Fred Drake | 7b87f85 | 2001-05-21 03:29:05 +0000 | [diff] [blame] | 367 | if (!PyArg_ParseTuple(args, "O|i:register", &o, &events)) { |
Andrew M. Kuchling | cf96dc8 | 2000-08-25 01:15:33 +0000 | [diff] [blame] | 368 | return NULL; |
| 369 | } |
| 370 | |
| 371 | fd = PyObject_AsFileDescriptor(o); |
| 372 | if (fd == -1) return NULL; |
| 373 | |
| 374 | /* Add entry to the internal dictionary: the key is the |
| 375 | file descriptor, and the value is the event mask. */ |
| 376 | if ( (NULL == (key = PyInt_FromLong(fd))) || |
| 377 | (NULL == (value = PyInt_FromLong(events))) || |
| 378 | (PyDict_SetItem(self->dict, key, value)) == -1) { |
| 379 | return NULL; |
| 380 | } |
| 381 | self->ufd_uptodate = 0; |
| 382 | |
| 383 | Py_INCREF(Py_None); |
| 384 | return Py_None; |
| 385 | } |
| 386 | |
| 387 | static char poll_unregister_doc[] = |
| 388 | "unregister(fd) -> None\n\n\ |
| 389 | Remove a file descriptor being tracked by the polling object."; |
| 390 | |
| 391 | static PyObject * |
| 392 | poll_unregister(pollObject *self, PyObject *args) |
| 393 | { |
| 394 | PyObject *o, *key; |
| 395 | int fd; |
| 396 | |
Fred Drake | 7b87f85 | 2001-05-21 03:29:05 +0000 | [diff] [blame] | 397 | if (!PyArg_ParseTuple(args, "O:unregister", &o)) { |
Andrew M. Kuchling | cf96dc8 | 2000-08-25 01:15:33 +0000 | [diff] [blame] | 398 | return NULL; |
| 399 | } |
| 400 | |
| 401 | fd = PyObject_AsFileDescriptor( o ); |
| 402 | if (fd == -1) |
| 403 | return NULL; |
| 404 | |
| 405 | /* Check whether the fd is already in the array */ |
| 406 | key = PyInt_FromLong(fd); |
| 407 | if (key == NULL) |
| 408 | return NULL; |
| 409 | |
| 410 | if (PyDict_DelItem(self->dict, key) == -1) { |
| 411 | Py_DECREF(key); |
| 412 | /* This will simply raise the KeyError set by PyDict_DelItem |
| 413 | if the file descriptor isn't registered. */ |
| 414 | return NULL; |
| 415 | } |
| 416 | |
| 417 | Py_DECREF(key); |
| 418 | self->ufd_uptodate = 0; |
| 419 | |
| 420 | Py_INCREF(Py_None); |
| 421 | return Py_None; |
| 422 | } |
| 423 | |
| 424 | static char poll_poll_doc[] = |
| 425 | "poll( [timeout] ) -> list of (fd, event) 2-tuples\n\n\ |
| 426 | Polls the set of registered file descriptors, returning a list containing \n\ |
| 427 | any descriptors that have events or errors to report."; |
| 428 | |
| 429 | static PyObject * |
| 430 | poll_poll(pollObject *self, PyObject *args) |
| 431 | { |
| 432 | PyObject *result_list = NULL, *tout = NULL; |
| 433 | int timeout = 0, poll_result, i, j; |
| 434 | PyObject *value = NULL, *num = NULL; |
| 435 | |
Fred Drake | 7b87f85 | 2001-05-21 03:29:05 +0000 | [diff] [blame] | 436 | if (!PyArg_ParseTuple(args, "|O:poll", &tout)) { |
Andrew M. Kuchling | cf96dc8 | 2000-08-25 01:15:33 +0000 | [diff] [blame] | 437 | return NULL; |
| 438 | } |
| 439 | |
| 440 | /* Check values for timeout */ |
| 441 | if (tout == NULL || tout == Py_None) |
| 442 | timeout = -1; |
| 443 | else if (!PyArg_Parse(tout, "i", &timeout)) { |
| 444 | PyErr_SetString(PyExc_TypeError, |
| 445 | "timeout must be an integer or None"); |
| 446 | return NULL; |
| 447 | } |
| 448 | |
| 449 | /* Ensure the ufd array is up to date */ |
| 450 | if (!self->ufd_uptodate) |
| 451 | if (update_ufd_array(self) == 0) |
| 452 | return NULL; |
| 453 | |
| 454 | /* call poll() */ |
| 455 | Py_BEGIN_ALLOW_THREADS; |
| 456 | poll_result = poll(self->ufds, self->ufd_len, timeout); |
| 457 | Py_END_ALLOW_THREADS; |
| 458 | |
| 459 | if (poll_result < 0) { |
| 460 | PyErr_SetFromErrno(SelectError); |
| 461 | return NULL; |
| 462 | } |
| 463 | |
| 464 | /* build the result list */ |
| 465 | |
| 466 | result_list = PyList_New(poll_result); |
| 467 | if (!result_list) |
| 468 | return NULL; |
| 469 | else { |
| 470 | for (i = 0, j = 0; j < poll_result; j++) { |
| 471 | /* skip to the next fired descriptor */ |
| 472 | while (!self->ufds[i].revents) { |
| 473 | i++; |
| 474 | } |
| 475 | /* if we hit a NULL return, set value to NULL |
| 476 | and break out of loop; code at end will |
| 477 | clean up result_list */ |
| 478 | value = PyTuple_New(2); |
| 479 | if (value == NULL) |
| 480 | goto error; |
| 481 | num = PyInt_FromLong(self->ufds[i].fd); |
| 482 | if (num == NULL) { |
| 483 | Py_DECREF(value); |
| 484 | goto error; |
| 485 | } |
| 486 | PyTuple_SET_ITEM(value, 0, num); |
| 487 | |
| 488 | num = PyInt_FromLong(self->ufds[i].revents); |
| 489 | if (num == NULL) { |
| 490 | Py_DECREF(value); |
| 491 | goto error; |
| 492 | } |
| 493 | PyTuple_SET_ITEM(value, 1, num); |
| 494 | if ((PyList_SetItem(result_list, j, value)) == -1) { |
| 495 | Py_DECREF(value); |
| 496 | goto error; |
| 497 | } |
| 498 | i++; |
| 499 | } |
| 500 | } |
| 501 | return result_list; |
| 502 | |
| 503 | error: |
| 504 | Py_DECREF(result_list); |
| 505 | return NULL; |
| 506 | } |
| 507 | |
| 508 | static PyMethodDef poll_methods[] = { |
| 509 | {"register", (PyCFunction)poll_register, |
| 510 | METH_VARARGS, poll_register_doc}, |
| 511 | {"unregister", (PyCFunction)poll_unregister, |
| 512 | METH_VARARGS, poll_unregister_doc}, |
| 513 | {"poll", (PyCFunction)poll_poll, |
| 514 | METH_VARARGS, poll_poll_doc}, |
| 515 | {NULL, NULL} /* sentinel */ |
| 516 | }; |
| 517 | |
| 518 | static pollObject * |
Fred Drake | 8ce159a | 2000-08-31 05:18:54 +0000 | [diff] [blame] | 519 | newPollObject(void) |
Andrew M. Kuchling | cf96dc8 | 2000-08-25 01:15:33 +0000 | [diff] [blame] | 520 | { |
| 521 | pollObject *self; |
| 522 | self = PyObject_New(pollObject, &poll_Type); |
| 523 | if (self == NULL) |
| 524 | return NULL; |
| 525 | /* ufd_uptodate is a Boolean, denoting whether the |
| 526 | array pointed to by ufds matches the contents of the dictionary. */ |
| 527 | self->ufd_uptodate = 0; |
| 528 | self->ufds = NULL; |
| 529 | self->dict = PyDict_New(); |
| 530 | if (self->dict == NULL) { |
| 531 | Py_DECREF(self); |
| 532 | return NULL; |
| 533 | } |
| 534 | return self; |
| 535 | } |
| 536 | |
| 537 | static void |
| 538 | poll_dealloc(pollObject *self) |
| 539 | { |
| 540 | if (self->ufds != NULL) |
| 541 | PyMem_DEL(self->ufds); |
| 542 | Py_XDECREF(self->dict); |
| 543 | PyObject_Del(self); |
| 544 | } |
| 545 | |
| 546 | static PyObject * |
| 547 | poll_getattr(pollObject *self, char *name) |
| 548 | { |
| 549 | return Py_FindMethod(poll_methods, (PyObject *)self, name); |
| 550 | } |
| 551 | |
| 552 | statichere PyTypeObject poll_Type = { |
| 553 | /* The ob_type field must be initialized in the module init function |
| 554 | * to be portable to Windows without using C++. */ |
| 555 | PyObject_HEAD_INIT(NULL) |
| 556 | 0, /*ob_size*/ |
| 557 | "poll", /*tp_name*/ |
| 558 | sizeof(pollObject), /*tp_basicsize*/ |
| 559 | 0, /*tp_itemsize*/ |
| 560 | /* methods */ |
| 561 | (destructor)poll_dealloc, /*tp_dealloc*/ |
| 562 | 0, /*tp_print*/ |
| 563 | (getattrfunc)poll_getattr, /*tp_getattr*/ |
| 564 | 0, /*tp_setattr*/ |
| 565 | 0, /*tp_compare*/ |
| 566 | 0, /*tp_repr*/ |
| 567 | 0, /*tp_as_number*/ |
| 568 | 0, /*tp_as_sequence*/ |
| 569 | 0, /*tp_as_mapping*/ |
| 570 | 0, /*tp_hash*/ |
| 571 | }; |
| 572 | |
| 573 | static char poll_doc[] = |
| 574 | "Returns a polling object, which supports registering and\n\ |
| 575 | unregistering file descriptors, and then polling them for I/O events."; |
| 576 | |
| 577 | static PyObject * |
| 578 | select_poll(PyObject *self, PyObject *args) |
| 579 | { |
| 580 | pollObject *rv; |
| 581 | |
| 582 | if (!PyArg_ParseTuple(args, ":poll")) |
| 583 | return NULL; |
| 584 | rv = newPollObject(); |
| 585 | if ( rv == NULL ) |
| 586 | return NULL; |
| 587 | return (PyObject *)rv; |
| 588 | } |
| 589 | #endif /* HAVE_POLL */ |
| 590 | |
Guido van Rossum | 1d8fb2d | 1998-06-28 16:54:49 +0000 | [diff] [blame] | 591 | static char select_doc[] = |
| 592 | "select(rlist, wlist, xlist[, timeout]) -> (rlist, wlist, xlist)\n\ |
| 593 | \n\ |
| 594 | Wait until one or more file descriptors are ready for some kind of I/O.\n\ |
| 595 | The first three arguments are lists of file descriptors to be waited for:\n\ |
| 596 | rlist -- wait until ready for reading\n\ |
| 597 | wlist -- wait until ready for writing\n\ |
| 598 | xlist -- wait for an ``exceptional condition''\n\ |
| 599 | If only one kind of condition is required, pass [] for the other lists.\n\ |
| 600 | A file descriptor is either a socket or file object, or a small integer\n\ |
| 601 | gotten from a fileno() method call on one of those.\n\ |
| 602 | \n\ |
| 603 | The optional 4th argument specifies a timeout in seconds; it may be\n\ |
| 604 | a floating point number to specify fractions of seconds. If it is absent\n\ |
| 605 | or None, the call will never time out.\n\ |
| 606 | \n\ |
| 607 | The return value is a tuple of three lists corresponding to the first three\n\ |
| 608 | arguments; each contains the subset of the corresponding file descriptors\n\ |
| 609 | that are ready.\n\ |
| 610 | \n\ |
| 611 | *** IMPORTANT NOTICE ***\n\ |
| 612 | On Windows, only sockets are supported; on Unix, all file descriptors."; |
| 613 | |
Barry Warsaw | e4ac0aa | 1996-12-12 00:04:35 +0000 | [diff] [blame] | 614 | static PyMethodDef select_methods[] = { |
Andrew M. Kuchling | cf96dc8 | 2000-08-25 01:15:33 +0000 | [diff] [blame] | 615 | {"select", select_select, METH_VARARGS, select_doc}, |
| 616 | #ifdef HAVE_POLL |
| 617 | {"poll", select_poll, METH_VARARGS, poll_doc}, |
| 618 | #endif /* HAVE_POLL */ |
Barry Warsaw | e4ac0aa | 1996-12-12 00:04:35 +0000 | [diff] [blame] | 619 | {0, 0}, /* sentinel */ |
Guido van Rossum | ed233a5 | 1992-06-23 09:07:03 +0000 | [diff] [blame] | 620 | }; |
| 621 | |
Guido van Rossum | 1d8fb2d | 1998-06-28 16:54:49 +0000 | [diff] [blame] | 622 | static char module_doc[] = |
| 623 | "This module supports asynchronous I/O on multiple file descriptors.\n\ |
| 624 | \n\ |
| 625 | *** IMPORTANT NOTICE ***\n\ |
| 626 | On Windows, only sockets are supported; on Unix, all file descriptors."; |
Guido van Rossum | ed233a5 | 1992-06-23 09:07:03 +0000 | [diff] [blame] | 627 | |
Andrew M. Kuchling | cf96dc8 | 2000-08-25 01:15:33 +0000 | [diff] [blame] | 628 | /* |
| 629 | * Convenience routine to export an integer value. |
| 630 | * For simplicity, errors (which are unlikely anyway) are ignored. |
| 631 | */ |
| 632 | |
| 633 | static void |
| 634 | insint(PyObject *d, char *name, int value) |
| 635 | { |
| 636 | PyObject *v = PyInt_FromLong((long) value); |
| 637 | if (v == NULL) { |
| 638 | /* Don't bother reporting this error */ |
| 639 | PyErr_Clear(); |
| 640 | } |
| 641 | else { |
| 642 | PyDict_SetItemString(d, name, v); |
| 643 | Py_DECREF(v); |
| 644 | } |
| 645 | } |
| 646 | |
Guido van Rossum | 3886bb6 | 1998-12-04 18:50:17 +0000 | [diff] [blame] | 647 | DL_EXPORT(void) |
Thomas Wouters | f3f33dc | 2000-07-21 06:00:07 +0000 | [diff] [blame] | 648 | initselect(void) |
Guido van Rossum | ed233a5 | 1992-06-23 09:07:03 +0000 | [diff] [blame] | 649 | { |
Barry Warsaw | e4ac0aa | 1996-12-12 00:04:35 +0000 | [diff] [blame] | 650 | PyObject *m, *d; |
Guido van Rossum | 1d8fb2d | 1998-06-28 16:54:49 +0000 | [diff] [blame] | 651 | m = Py_InitModule3("select", select_methods, module_doc); |
Barry Warsaw | e4ac0aa | 1996-12-12 00:04:35 +0000 | [diff] [blame] | 652 | d = PyModule_GetDict(m); |
Guido van Rossum | 0cb96de | 1997-10-01 04:29:29 +0000 | [diff] [blame] | 653 | SelectError = PyErr_NewException("select.error", NULL, NULL); |
Barry Warsaw | e4ac0aa | 1996-12-12 00:04:35 +0000 | [diff] [blame] | 654 | PyDict_SetItemString(d, "error", SelectError); |
Andrew M. Kuchling | cf96dc8 | 2000-08-25 01:15:33 +0000 | [diff] [blame] | 655 | #ifdef HAVE_POLL |
| 656 | poll_Type.ob_type = &PyType_Type; |
| 657 | insint(d, "POLLIN", POLLIN); |
| 658 | insint(d, "POLLPRI", POLLPRI); |
| 659 | insint(d, "POLLOUT", POLLOUT); |
| 660 | insint(d, "POLLERR", POLLERR); |
| 661 | insint(d, "POLLHUP", POLLHUP); |
| 662 | insint(d, "POLLNVAL", POLLNVAL); |
| 663 | |
Andrew M. Kuchling | 36d97eb | 2000-09-28 21:33:44 +0000 | [diff] [blame] | 664 | #ifdef POLLRDNORM |
Andrew M. Kuchling | cf96dc8 | 2000-08-25 01:15:33 +0000 | [diff] [blame] | 665 | insint(d, "POLLRDNORM", POLLRDNORM); |
Andrew M. Kuchling | 36d97eb | 2000-09-28 21:33:44 +0000 | [diff] [blame] | 666 | #endif |
| 667 | #ifdef POLLRDBAND |
Andrew M. Kuchling | cf96dc8 | 2000-08-25 01:15:33 +0000 | [diff] [blame] | 668 | insint(d, "POLLRDBAND", POLLRDBAND); |
Andrew M. Kuchling | 36d97eb | 2000-09-28 21:33:44 +0000 | [diff] [blame] | 669 | #endif |
| 670 | #ifdef POLLWRNORM |
Andrew M. Kuchling | cf96dc8 | 2000-08-25 01:15:33 +0000 | [diff] [blame] | 671 | insint(d, "POLLWRNORM", POLLWRNORM); |
Andrew M. Kuchling | 36d97eb | 2000-09-28 21:33:44 +0000 | [diff] [blame] | 672 | #endif |
| 673 | #ifdef POLLWRBAND |
Andrew M. Kuchling | cf96dc8 | 2000-08-25 01:15:33 +0000 | [diff] [blame] | 674 | insint(d, "POLLWRBAND", POLLWRBAND); |
Andrew M. Kuchling | 36d97eb | 2000-09-28 21:33:44 +0000 | [diff] [blame] | 675 | #endif |
Sjoerd Mullender | 239f836 | 2000-08-25 13:59:18 +0000 | [diff] [blame] | 676 | #ifdef POLLMSG |
Andrew M. Kuchling | cf96dc8 | 2000-08-25 01:15:33 +0000 | [diff] [blame] | 677 | insint(d, "POLLMSG", POLLMSG); |
Sjoerd Mullender | 239f836 | 2000-08-25 13:59:18 +0000 | [diff] [blame] | 678 | #endif |
Andrew M. Kuchling | cf96dc8 | 2000-08-25 01:15:33 +0000 | [diff] [blame] | 679 | #endif /* HAVE_POLL */ |
Guido van Rossum | ed233a5 | 1992-06-23 09:07:03 +0000 | [diff] [blame] | 680 | } |