Bug 43152 - apr_socket_opt_get doesn't work with APR_SO_SNDBUF and APR_SO_RCVBUF
Summary: apr_socket_opt_get doesn't work with APR_SO_SNDBUF and APR_SO_RCVBUF
Status: NEEDINFO
Alias: None
Product: APR
Classification: Unclassified
Component: APR (show other bugs)
Version: 1.2.8
Hardware: All All
: P3 normal (vote)
Target Milestone: ---
Assignee: Apache Portable Runtime bugs mailinglist
URL:
Keywords:
Depends on:
Blocks: 43153
  Show dependency tree
 
Reported: 2007-08-16 19:21 UTC by Chris Elving
Modified: 2007-08-17 14:14 UTC (History)
0 users



Attachments
Implement APR_SO_SNDBUF and APR_SO_RCVBUF in apr_socket_opt_get (844 bytes, patch)
2007-08-16 19:23 UTC, Chris Elving
Details | Diff
Fix getsockopt/setsockopt typo in previous patch (844 bytes, patch)
2007-08-17 13:07 UTC, Chris Elving
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Chris Elving 2007-08-16 19:21:03 UTC
apr_socket_opt_get(socket, APR_SO_SNDBUF, &opt) and apr_socket_opt_get(socket,
APR_SO_RCVBUF, &opt) always set opt to 0. It would be useful if these calls
instead returned the send buffer and receive buffer sizes respectively.
Comment 1 Chris Elving 2007-08-16 19:23:44 UTC
Created attachment 20671 [details]
Implement APR_SO_SNDBUF and APR_SO_RCVBUF in apr_socket_opt_get
Comment 2 Ruediger Pluem 2007-08-17 12:59:58 UTC
Why using setsockopt in the SO_RCVBUF case?
Comment 3 Chris Elving 2007-08-17 13:06:49 UTC
Comment on attachment 20671 [details]
Implement APR_SO_SNDBUF and APR_SO_RCVBUF in apr_socket_opt_get

Patch mistakenly used setsockopt instead of getsockopt for SO_RCVBUF
Comment 4 Chris Elving 2007-08-17 13:07:36 UTC
Created attachment 20676 [details]
Fix getsockopt/setsockopt typo in previous patch
Comment 5 Ruediger Pluem 2007-08-17 13:30:49 UTC
Please keep in mind the following comment from the Linux man page for SO_RCVBUF,
SO_RCVBUF:

              Sets  or  gets  the maximum socket receive buffer in bytes.  The
              kernel doubles this value (to allow space for bookkeeping  over-
              head)  when it is set using setsockopt(), and this doubled value
              is returned by getsockopt().

There is no such hint on the man page of e.g. Solaris. In the case that other OS
(e.g. Solaris) do not modify the buffer size given with setsockopt, your patch
is not portable. Especially if someone wants to use the result of
apr_socket_opt_get for a apr_socket_opt_set in a platform independent way.
Comment 6 Chris Elving 2007-08-17 14:14:10 UTC
I don't think this patch introduces any new portability issues. The semantics of
the current apr_socket_opt_set(..., APR_SO_SNDBUF, ...) aren't portable, but
this patch shouldn't change that.