select.c (302408) | select.c (362181) |
---|---|
1/* Licensed to the Apache Software Foundation (ASF) under one or more 2 * contributor license agreements. See the NOTICE file distributed with 3 * this work for additional information regarding copyright ownership. 4 * The ASF licenses this file to You under the Apache License, Version 2.0 5 * (the "License"); you may not use this file except in compliance with 6 * the License. You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 --- 333 unchanged lines hidden (view full) --- 342 const apr_pollfd_t **descriptors) 343{ 344 int rs; 345 apr_uint32_t i, j; 346 struct timeval tv, *tvptr; 347 fd_set readset, writeset, exceptset; 348 apr_status_t rv = APR_SUCCESS; 349 | 1/* Licensed to the Apache Software Foundation (ASF) under one or more 2 * contributor license agreements. See the NOTICE file distributed with 3 * this work for additional information regarding copyright ownership. 4 * The ASF licenses this file to You under the Apache License, Version 2.0 5 * (the "License"); you may not use this file except in compliance with 6 * the License. You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 --- 333 unchanged lines hidden (view full) --- 342 const apr_pollfd_t **descriptors) 343{ 344 int rs; 345 apr_uint32_t i, j; 346 struct timeval tv, *tvptr; 347 fd_set readset, writeset, exceptset; 348 apr_status_t rv = APR_SUCCESS; 349 |
350 *num = 0; 351 |
|
350#ifdef WIN32 351 /* On Win32, select() must be presented with at least one socket to 352 * poll on, or select() will return WSAEINVAL. So, we'll just 353 * short-circuit and bail now. 354 */ 355 if (pollset->nelts == 0) { | 352#ifdef WIN32 353 /* On Win32, select() must be presented with at least one socket to 354 * poll on, or select() will return WSAEINVAL. So, we'll just 355 * short-circuit and bail now. 356 */ 357 if (pollset->nelts == 0) { |
356 (*num) = 0; | |
357 if (timeout > 0) { 358 apr_sleep(timeout); 359 return APR_TIMEUP; 360 } 361 return APR_SUCCESS; 362 } 363#endif 364 --- 15 unchanged lines hidden (view full) --- 380 rs = pipe_select(pollset->p->maxfd + 1, &readset, &writeset, &exceptset, 381 tvptr); 382 } 383 else 384#endif 385 rs = select(pollset->p->maxfd + 1, &readset, &writeset, &exceptset, 386 tvptr); 387 | 358 if (timeout > 0) { 359 apr_sleep(timeout); 360 return APR_TIMEUP; 361 } 362 return APR_SUCCESS; 363 } 364#endif 365 --- 15 unchanged lines hidden (view full) --- 381 rs = pipe_select(pollset->p->maxfd + 1, &readset, &writeset, &exceptset, 382 tvptr); 383 } 384 else 385#endif 386 rs = select(pollset->p->maxfd + 1, &readset, &writeset, &exceptset, 387 tvptr); 388 |
388 (*num) = rs; | |
389 if (rs < 0) { 390 return apr_get_netos_error(); 391 } 392 if (rs == 0) { 393 return APR_TIMEUP; 394 } 395 j = 0; 396 for (i = 0; i < pollset->nelts; i++) { 397 apr_os_sock_t fd; 398 if (pollset->p->query_set[i].desc_type == APR_POLL_SOCKET) { 399 fd = pollset->p->query_set[i].desc.s->socketdes; 400 } 401 else { 402 if ((pollset->flags & APR_POLLSET_WAKEABLE) && 403 pollset->p->query_set[i].desc.f == pollset->wakeup_pipe[0]) { | 389 if (rs < 0) { 390 return apr_get_netos_error(); 391 } 392 if (rs == 0) { 393 return APR_TIMEUP; 394 } 395 j = 0; 396 for (i = 0; i < pollset->nelts; i++) { 397 apr_os_sock_t fd; 398 if (pollset->p->query_set[i].desc_type == APR_POLL_SOCKET) { 399 fd = pollset->p->query_set[i].desc.s->socketdes; 400 } 401 else { 402 if ((pollset->flags & APR_POLLSET_WAKEABLE) && 403 pollset->p->query_set[i].desc.f == pollset->wakeup_pipe[0]) { |
404 apr_pollset_drain_wakeup_pipe(pollset); | 404 apr_poll_drain_wakeup_pipe(pollset->wakeup_pipe); |
405 rv = APR_EINTR; 406 continue; 407 } 408 else { 409#if !APR_FILES_AS_SOCKETS 410 return APR_EBADF; 411#else 412 fd = pollset->p->query_set[i].desc.f->filedes; --- 19 unchanged lines hidden (view full) --- 432 if (((*num) = j) != 0) 433 rv = APR_SUCCESS; 434 435 if (descriptors) 436 *descriptors = pollset->p->result_set; 437 return rv; 438} 439 | 405 rv = APR_EINTR; 406 continue; 407 } 408 else { 409#if !APR_FILES_AS_SOCKETS 410 return APR_EBADF; 411#else 412 fd = pollset->p->query_set[i].desc.f->filedes; --- 19 unchanged lines hidden (view full) --- 432 if (((*num) = j) != 0) 433 rv = APR_SUCCESS; 434 435 if (descriptors) 436 *descriptors = pollset->p->result_set; 437 return rv; 438} 439 |
440static apr_pollset_provider_t impl = { | 440static const apr_pollset_provider_t impl = { |
441 impl_pollset_create, 442 impl_pollset_add, 443 impl_pollset_remove, 444 impl_pollset_poll, 445 NULL, 446 "select" 447}; 448 | 441 impl_pollset_create, 442 impl_pollset_add, 443 impl_pollset_remove, 444 impl_pollset_poll, 445 NULL, 446 "select" 447}; 448 |
449apr_pollset_provider_t *apr_pollset_provider_select = &impl; | 449const apr_pollset_provider_t *apr_pollset_provider_select = &impl; |