| 3487 | |
| 3488 | #if USE_ALTERNATE_IS_CONNECTED && defined(APR_MSG_PEEK) |
| 3489 | PROXY_DECLARE(int) ap_proxy_is_socket_connected(apr_socket_t *socket) |
| 3490 | { |
| 3491 | apr_pollfd_t pfds[1]; |
| 3492 | apr_status_t status; |
| 3493 | apr_int32_t nfds; |
| 3494 | |
| 3495 | pfds[0].reqevents = APR_POLLIN; |
| 3496 | pfds[0].desc_type = APR_POLL_SOCKET; |
| 3497 | pfds[0].desc.s = socket; |
| 3498 | |
| 3499 | do { |
| 3500 | status = apr_poll(&pfds[0], 1, &nfds, 0); |
| 3501 | } while (APR_STATUS_IS_EINTR(status)); |
| 3502 | |
| 3503 | if (status == APR_SUCCESS && nfds == 1 && |
| 3504 | pfds[0].rtnevents == APR_POLLIN) { |
| 3505 | apr_sockaddr_t unused; |
| 3506 | apr_size_t len = 1; |
| 3507 | char buf[1]; |
| 3508 | /* The socket might be closed in which case |
| 3509 | * the poll will return POLLIN. |
| 3510 | * If there is no data available the socket |
| 3511 | * is closed. |
| 3512 | */ |
| 3513 | status = apr_socket_recvfrom(&unused, socket, APR_MSG_PEEK, |
| 3514 | &buf[0], &len); |
| 3515 | if (status == APR_SUCCESS && len) |
| 3516 | return 1; |
| 3517 | else |
| 3518 | return 0; |
| 3519 | } |
| 3520 | else if (APR_STATUS_IS_EAGAIN(status) || APR_STATUS_IS_TIMEUP(status)) { |
| 3521 | return 1; |
| 3522 | } |
| 3523 | return 0; |
| 3524 | |
| 3525 | } |
| 3526 | #else |
| 3527 | PROXY_DECLARE(int) ap_proxy_is_socket_connected(apr_socket_t *sock) |
| 3528 |
no outgoing calls
no test coverage detected