Paul Querna wrote:
> Adds: apr_bucket_socket_get_peer() and has the bucket read call recvfrom().
>
> Based on an earlier patch from Issac Goldstand.
>
[..]
> - rv = apr_socket_recv(p, buf, len);
> + apr_socket_type_get(p, &sd_type);
> + if (sd_type == SOCK_STREAM) {
> + rv = apr_socket_recv(p, buf, len);
> + } else {
> + /* Is socket connected? */
> + if (apr_socket_addr_get(&baton->peer, APR_REMOTE, p) != APR_SUCCESS)
> {
> + rv = apr_socket_recv(p, buf, len);
> + } else {
> + if (!baton->peer) {
> + baton->peer = apr_bucket_alloc(sizeof(*baton->peer),
> a->list);
> + }
> + /* Caller is responsible for detecting peer on his own if needed
> */
> + rv = apr_socket_recvfrom(baton->peer, p, 0, buf, len);
> + }
> + }
Why not cache the the peer and avoid a call to apr_socket_addr_get on
every read?
Regards,
Davi Arnaut