1 | /* |
1 | /* |
|
|
2 | * libev select fd activity backend |
|
|
3 | * |
2 | * Copyright (c) 2007 Marc Alexander Lehmann <libev@schmorp.de> |
4 | * Copyright (c) 2007 Marc Alexander Lehmann <libev@schmorp.de> |
3 | * All rights reserved. |
5 | * All rights reserved. |
4 | * |
6 | * |
5 | * Redistribution and use in source and binary forms, with or without |
7 | * Redistribution and use in source and binary forms, with or without |
6 | * modification, are permitted provided that the following conditions are |
8 | * modification, are permitted provided that the following conditions are |
… | |
… | |
68 | vec_wi [offs] |= mask; |
70 | vec_wi [offs] |= mask; |
69 | if (!(nev & EV_WRITE)) |
71 | if (!(nev & EV_WRITE)) |
70 | vec_wi [offs] &= ~mask; |
72 | vec_wi [offs] &= ~mask; |
71 | } |
73 | } |
72 | |
74 | |
|
|
75 | static void |
73 | static void select_poll (ev_tstamp timeout) |
76 | select_poll (ev_tstamp timeout) |
74 | { |
77 | { |
75 | struct timeval tv; |
78 | struct timeval tv; |
76 | int res; |
79 | int res; |
77 | |
80 | |
78 | memcpy (vec_ro, vec_ri, vec_max * 4); |
81 | memcpy (vec_ro, vec_ri, vec_max * 4); |
… | |
… | |
115 | if (errno == EBADF) |
118 | if (errno == EBADF) |
116 | fd_recheck (); |
119 | fd_recheck (); |
117 | } |
120 | } |
118 | } |
121 | } |
119 | |
122 | |
|
|
123 | static void |
120 | void select_init (int flags) |
124 | select_init (int flags) |
121 | { |
125 | { |
122 | ev_method = EVMETHOD_SELECT; |
126 | ev_method = EVMETHOD_SELECT; |
123 | method_fudge = 1e-2; /* needed to compensate for select returning early, very conservative */ |
127 | method_fudge = 1e-2; /* needed to compensate for select returning early, very conservative */ |
124 | method_modify = select_modify; |
128 | method_modify = select_modify; |
125 | method_poll = select_poll; |
129 | method_poll = select_poll; |
126 | } |
130 | } |
127 | |
131 | |
128 | |
|
|