| 156 | } |
| 157 | |
| 158 | static int check_dirty(lua_State *L, int tab, int dtab, fd_set *set) { |
| 159 | int ndirty = 0, i = 1; |
| 160 | if (lua_isnil(L, tab)) |
| 161 | return 0; |
| 162 | for ( ;; ) { |
| 163 | t_socket fd; |
| 164 | lua_pushnumber(L, i); |
| 165 | lua_gettable(L, tab); |
| 166 | if (lua_isnil(L, -1)) { |
| 167 | lua_pop(L, 1); |
| 168 | break; |
| 169 | } |
| 170 | fd = getfd(L); |
| 171 | if (fd != SOCKET_INVALID && dirty(L)) { |
| 172 | lua_pushnumber(L, ++ndirty); |
| 173 | lua_pushvalue(L, -2); |
| 174 | lua_settable(L, dtab); |
| 175 | FD_CLR(fd, set); |
| 176 | } |
| 177 | lua_pop(L, 1); |
| 178 | i = i + 1; |
| 179 | } |
| 180 | return ndirty; |
| 181 | } |
| 182 | |
| 183 | static void return_fd(lua_State *L, fd_set *set, t_socket max_fd, |
| 184 | int itab, int tab, int start) { |
no test coverage detected