httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ryan Bloom <>
Subject Re: cvs commit: apache-apr/apr/network_io/unix sockets.c
Date Fri, 23 Apr 1999 20:00:38 GMT
> >   Index: networkio.txt
> >   ===================================================================
> >...
> >   + apr_status_t apr_socket_valid(apr_socket_t *)
> >   +       is the socket that was created valid?
> >   +     Arguments:
> >   +       arg 1)  The socket to check
> >   +       return) APR_SUCCESS or APR_FAILURE
> Wrong name here. Should be apr_valid_socket().

Shoot, you're right.  And I changed it from what David sent me, because I
read what I did for the file stuff wrong.  Thanks.

> I fail to see how this is useful. If an error is returned when the
> socket was created (well attempted), then why would somebody keep the
> thing around? If the returned socket is not thrown away immediately,
> then you'll end up with one of two problems: 1) somebody forgets to
> check and the app does Bad Things; 2) you have to litter the code with
> apr_valid_socket() calls.
> Looking at the patch where you use this, I would suggest that you just
> check for a NULL return value from apr_create_tcp_socket(). In fact, I'm
> surprised your call to apr_valid_socket() worked at all, since it
> de-refs "sock" without testing for NULL. This would imply that
> apr_create_tcp_socket() is not returning NULL if an error occurs. That
> should be fixed, rather than compensating for the fact with
> apr_valid_socket().

Actually, apr_create_tcp_socket does return NULL the correct way.  The
reason this function was created, was to mirror the file stuff.  You're
right, strictly speaking this function isn't needed, and the right way to
do things, would be to check for NULL in the test program.  I am using it
in the test program, to exercise the function, not because it is the only
way to make this check.  I forget why I put in the apr_valid_file call,
but I know I had a reason to when I did it.  I'll have to think about that
again.  If I can't remember why I thought I needed the apr_*_valid
functions, I will back them all out this weekend.

If I do remember, I'll post why I thought they were necessary, and let you
flame me for it.

At some point (and it may have been on my own machine only), I was
checking the return code of apr_create_tcp_socket for NULL, but I removed
it to stress the apr_socket_valid function.

I'll probably reomve them tomorrow, but right now, I am ankle deep in
process testing, and I really want to finish it.  :)


Ryan Bloom
4205 S Miami Blvd	
RTP, NC 27709		It's a beautiful sight to see good dancers 
			doing simple steps.  It's a painful sight to
			see beginners doing complicated patterns.	

View raw message