* Set the appropriate output bits given a mask of fired events and the * input bits originally requested. */
| 1277 | * input bits originally requested. |
| 1278 | */ |
| 1279 | static __inline int |
| 1280 | selsetbits(fd_mask **ibits, fd_mask **obits, int idx, fd_mask bit, int events) |
| 1281 | { |
| 1282 | int msk; |
| 1283 | int n; |
| 1284 | |
| 1285 | n = 0; |
| 1286 | for (msk = 0; msk < 3; msk++) { |
| 1287 | if ((events & select_flags[msk]) == 0) |
| 1288 | continue; |
| 1289 | if (ibits[msk] == NULL) |
| 1290 | continue; |
| 1291 | if ((ibits[msk][idx] & bit) == 0) |
| 1292 | continue; |
| 1293 | /* |
| 1294 | * XXX Check for a duplicate set. This can occur because a |
| 1295 | * socket calls selrecord() twice for each poll() call |
| 1296 | * resulting in two selfds per real fd. selrescan() will |
| 1297 | * call selsetbits twice as a result. |
| 1298 | */ |
| 1299 | if ((obits[msk][idx] & bit) != 0) |
| 1300 | continue; |
| 1301 | obits[msk][idx] |= bit; |
| 1302 | n++; |
| 1303 | } |
| 1304 | |
| 1305 | return (n); |
| 1306 | } |
| 1307 | |
| 1308 | /* |
| 1309 | * Traverse the list of fds attached to this thread's seltd and check for |