You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@httpd.apache.org by David Reid <ab...@dial.pipex.com> on 1999/10/03 22:18:15 UTC

[PATCH] APR socket timeouts...

I couldn't figure out why the testsock test was failing constantly on 
BeOS.  It looked like a synchronisation issue, which it didn't have 
before!  Of course it was the timeouts!  I realised that there isn't 
actually code to get/set the timeout into the socket structure, so here 
are some.

Addition to apr_network_io.h
ap_status_t ap_settimeout(ap_socket_t *, ap_uint32_t );
ap_status_t ap_gettimeout(ap_socket_t *, ap_uint32_t *); 

Addition to sockets.c
ap_status_t ap_settimeout(struct socket_t *sock, ap_uint32_t time) 
{
    sock->timeout = time;
    return APR_SUCCESS;
}

ap_status_t ap_gettimeout(struct socket_t *sock, ap_uint32_t *time) 
{
    *time = sock->timeout;
    return APR_SUCCESS;
}

This code goes into the client.c test program...
    fprintf(stdout, "\tClient:  Setting timeout for socket.....");
    if (ap_settimeout(sock, 5) != APR_SUCCESS) {
        fprintf(stderr,"Failed!\n***The test may fail, but it's not 
fatal***\n");
    } else 
        fprintf(stdout,"OK\n");

I haven't failed the test because the timeout couldn't be set, just 
warned the user.  the reason is that the code performs fine without a 
timeout on FreeBSD 3.3.  I'd guess it's the frenetic pace of BeOS 
threads that's causing the problem.

david

Re: [PATCH] APR socket timeouts...

Posted by Ryan Bloom <rb...@raleigh.ibm.com>.
This code is already in the unix networking code.  It is done through the
ap_setsocketopt function.  Just use the APR_SO_TIMEOUT option.  I have
modified the docs a tiny little bit to make it sound like you can do more
than just turn options on or off, you can also set values.

We still need the change to client.c, but I don't think we need a whole
new API for this change.  We could probably use an ap_getsocketopt call
though.  :)

Let me know if what we have can work for BeOS.

Ryan

On Sun, 3 Oct 1999, David Reid wrote:

> I couldn't figure out why the testsock test was failing constantly on 
> BeOS.  It looked like a synchronisation issue, which it didn't have 
> before!  Of course it was the timeouts!  I realised that there isn't 
> actually code to get/set the timeout into the socket structure, so here 
> are some.
> 
> Addition to apr_network_io.h
> ap_status_t ap_settimeout(ap_socket_t *, ap_uint32_t );
> ap_status_t ap_gettimeout(ap_socket_t *, ap_uint32_t *); 
> 

_______________________________________________________________________
Ryan Bloom		rbb@raleigh.ibm.com
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.