You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@httpd.apache.org by Cliff Woolley <cl...@yahoo.com> on 2001/08/08 02:37:21 UTC

Re: cvs commit: apr/network_io/unix sockets.c

On 8 Aug 2001 trawick@apache.org wrote:

> trawick     01/08/07 17:30:26
>
>   Modified:    network_io/unix sockets.c
>   Log:
>   get sockets.c to compile and fix a bug in the error path
>   from getsockopt()
>
>   (not tested... 2 yr old is begging for a walk :) )
>
>   Revision  Changes    Path
>   1.86      +3 -2      apr/network_io/unix/sockets.c
>
>   Index: sockets.c
>   ===================================================================
>   RCS file: /home/cvs/apr/network_io/unix/sockets.c,v
>   retrieving revision 1.85
>   retrieving revision 1.86
>   diff -u -r1.85 -r1.86
>   --- sockets.c	2001/08/07 23:56:35	1.85
>   +++ sockets.c	2001/08/08 00:30:17	1.86
>   @@ -275,12 +275,13 @@
>        if (rc == -1 && (errno == EINPROGRESS || errno == EALREADY) && sock->timeout != 0) {
>            int error;
>            apr_size_t len = sizeof(error);
>   +
>            rc = apr_wait_for_io_or_timeout(sock, 0);
>            if (rc != APR_SUCCESS) {
>                return rc;
>            }
>   -        if ((rc = getsockopt(sockfd, SOL_SOCKET, SO_ERROR, &error, &len)) < 0) {
>   -            return(rc);
>   +        if ((rc = getsockopt(sock->socketdes, SOL_SOCKET, SO_ERROR, &error, &len)) < 0) {
>   +            return errno;
>            }
>            if (error) {
>                return error;
>

Looks good to me.  Tag bumped.

--Cliff

--------------------------------------------------------------
   Cliff Woolley
   cliffwoolley@yahoo.com
   Charlottesville, VA



Re: cvs commit: apr/network_io/unix sockets.c

Posted by Cliff Woolley <cl...@yahoo.com>.
On 7 Aug 2001, Jeff Trawick wrote:

> yes, int is better than apr_size_t
>
> actually, I suspect apr_socklen_t is best overall, in case socklen_t
> is not int on some system?  (apr_socklen_t is socklen_t if the system
> defines it, int otherwise)
...
> I would vote for apr_socklen_t, but I doubt it would compile without
> warning everywhere (int won't either).

apr_socklen_t seems to work all around (tested on Sol 2.6, RHL7.1, FreeBSD
4.3, visually inspected on msdn for win32).

But you know what?  I'm an idiot and just plain can't count... it was
never the len parameter that was giving me trouble on Solaris 2.6 in the
first place... it was the error parameter, which is currently an int
getting passed in as an int* (assuming the function expects void*).  For
some funky ass reason, Solaris 2.6 ifndef _XPG4_2 (and apparently Win32 as
well, if msdn.microsoft.com is correct) expect it to be a char*!
Obviously, you can't convert an int* to a char* without a cast, so the
warning is perfectly valid.  Casting it to (char *), while ugly, seems to
fix the problem on all the platforms I can test.  If there's any platform
out there that expects something other than char* or void*, they can just
deal.  =-)

--Cliff

--------------------------------------------------------------
   Cliff Woolley
   cliffwoolley@yahoo.com
   Charlottesville, VA





Re: cvs commit: apr/network_io/unix sockets.c

Posted by Jeff Trawick <tr...@attglobal.net>.
Cliff Woolley <cl...@yahoo.com> writes:

> On Tue, 7 Aug 2001, Cliff Woolley wrote:
> 
> > > + if ((rc = getsockopt(sock->socketdes, SOL_SOCKET, SO_ERROR,
> > &error, &len)) < 0) {
> 
> It seems that len really ought to be an int, not an apr_size_t... I'm
> getting incompatible pointer type warnings on Solaris.

yes, int is better than apr_size_t

actually, I suspect apr_socklen_t is best overall, in case socklen_t
is not int on some system?  (apr_socklen_t is socklen_t if the system
defines it, int otherwise)

(ssh to Tru64)
socklen_t can be unsigned long (64-bit) on Tru64; int wouldn't be cool
there 

(ssh to HP-UX 11)
we're not picking up the modern socklen_t flavor of decls on HP-UX, so
we may possibly pick up another socklen_t warning there (like on
accept()) until that is fixed; not a new problem

(ssh to FreeBSD 3.4)
no problem... apr_socklen_t is int anyway, and getsockopt() takes int * 

I would vote for apr_socklen_t, but I doubt it would compile without
warning everywhere (int won't either).

> I checked the man pages on Solaris, HP-UX, and msdn.microsoft.com, and
> they all specifically say "int" for SO_ERROR.

"int" for SO_ERROR would indicate the type of the 4th parameter to
getsockopt(), not the type of len, which is the same for all
levels/options

-- 
Jeff Trawick | trawick@attglobal.net | PGP public key at web site:
       http://www.geocities.com/SiliconValley/Park/9289/
             Born in Roswell... married an alien...

Re: cvs commit: apr/network_io/unix sockets.c

Posted by Cliff Woolley <cl...@yahoo.com>.
On Tue, 7 Aug 2001, Cliff Woolley wrote:

> > + if ((rc = getsockopt(sock->socketdes, SOL_SOCKET, SO_ERROR,
> &error, &len)) < 0) {

It seems that len really ought to be an int, not an apr_size_t... I'm
getting incompatible pointer type warnings on Solaris.

I checked the man pages on Solaris, HP-UX, and msdn.microsoft.com, and
they all specifically say "int" for SO_ERROR.

Does that jive?

--Cliff

--------------------------------------------------------------
   Cliff Woolley
   cliffwoolley@yahoo.com
   Charlottesville, VA