| 2239 | } |
| 2240 | |
| 2241 | static bool select_wait( rem_port* main_port, Select* selct) |
| 2242 | { |
| 2243 | /************************************** |
| 2244 | * |
| 2245 | * s e l e c t _ w a i t |
| 2246 | * |
| 2247 | ************************************** |
| 2248 | * |
| 2249 | * Functional description |
| 2250 | * Select interesting descriptors from |
| 2251 | * port blocks and wait for something |
| 2252 | * to read from them. |
| 2253 | * |
| 2254 | **************************************/ |
| 2255 | struct timeval timeout; |
| 2256 | bool checkPorts = false; |
| 2257 | |
| 2258 | for (;;) |
| 2259 | { |
| 2260 | selct->clear(); |
| 2261 | bool found = false; |
| 2262 | |
| 2263 | // Use the time interval between select() calls to expire |
| 2264 | // keepalive timers on all ports. |
| 2265 | |
| 2266 | time_t delta_time; |
| 2267 | if (selct->slct_time) |
| 2268 | { |
| 2269 | delta_time = time(NULL) - selct->slct_time; |
| 2270 | selct->slct_time += delta_time; |
| 2271 | } |
| 2272 | else |
| 2273 | { |
| 2274 | delta_time = 0; |
| 2275 | selct->slct_time = time(NULL); |
| 2276 | } |
| 2277 | |
| 2278 | { // port_mutex scope |
| 2279 | MutexLockGuard guard(port_mutex, FB_FUNCTION); |
| 2280 | |
| 2281 | while (ports_to_close->hasData()) |
| 2282 | { |
| 2283 | SOCKET s = ports_to_close->pop(); |
| 2284 | SOCLOSE(s); |
| 2285 | } |
| 2286 | |
| 2287 | for (rem_port* port = main_port; port; port = port->port_next) |
| 2288 | { |
| 2289 | if (port->port_state == rem_port::PENDING && |
| 2290 | // don't wait on still listening (not connected) async port |
| 2291 | !(port->port_handle == INVALID_SOCKET && (port->port_flags & PORT_async))) |
| 2292 | { |
| 2293 | // Adjust down the port's keepalive timer. |
| 2294 | |
| 2295 | if (port->port_dummy_packet_interval) |
| 2296 | { |
| 2297 | port->port_dummy_timeout -= delta_time; |
| 2298 | } |
no test coverage detected