1 | /* |
1 | /* |
2 | * libev poll fd activity backend |
2 | * libev poll fd activity backend |
3 | * |
3 | * |
4 | * Copyright (c) 2007 Marc Alexander Lehmann <libev@schmorp.de> |
4 | * Copyright (c) 2007,2008 Marc Alexander Lehmann <libev@schmorp.de> |
5 | * All rights reserved. |
5 | * All rights reserved. |
6 | * |
6 | * |
7 | * Redistribution and use in source and binary forms, with or without modifica- |
7 | * Redistribution and use in source and binary forms, with or without modifica- |
8 | * tion, are permitted provided that the following conditions are met: |
8 | * tion, are permitted provided that the following conditions are met: |
9 | * |
9 | * |
… | |
… | |
96 | else if (errno == ENOMEM && !syserr_cb) |
96 | else if (errno == ENOMEM && !syserr_cb) |
97 | fd_enomem (EV_A); |
97 | fd_enomem (EV_A); |
98 | else if (errno != EINTR) |
98 | else if (errno != EINTR) |
99 | syserr ("(libev) poll"); |
99 | syserr ("(libev) poll"); |
100 | } |
100 | } |
|
|
101 | else |
|
|
102 | for (p = polls; res; ++p) |
|
|
103 | if (expect_false (p->revents)) /* this expect is debatable */ |
|
|
104 | { |
|
|
105 | --res; |
101 | |
106 | |
102 | for (p = polls; res; ++p) |
|
|
103 | if (expect_false (p->revents)) /* this expect is debatable */ |
|
|
104 | { |
|
|
105 | --res; |
|
|
106 | |
|
|
107 | if (expect_false (p->revents & POLLNVAL)) |
107 | if (expect_false (p->revents & POLLNVAL)) |
108 | fd_kill (EV_A_ p->fd); |
108 | fd_kill (EV_A_ p->fd); |
109 | else |
109 | else |
110 | fd_event ( |
110 | fd_event ( |
111 | EV_A_ |
111 | EV_A_ |
112 | p->fd, |
112 | p->fd, |
113 | (p->revents & (POLLOUT | POLLERR | POLLHUP) ? EV_WRITE : 0) |
113 | (p->revents & (POLLOUT | POLLERR | POLLHUP) ? EV_WRITE : 0) |
114 | | (p->revents & (POLLIN | POLLERR | POLLHUP) ? EV_READ : 0) |
114 | | (p->revents & (POLLIN | POLLERR | POLLHUP) ? EV_READ : 0) |
115 | ); |
115 | ); |
116 | } |
116 | } |
117 | } |
117 | } |
118 | |
118 | |
119 | int inline_size |
119 | int inline_size |
120 | poll_init (EV_P_ int flags) |
120 | poll_init (EV_P_ int flags) |
121 | { |
121 | { |