diff options
author | mturk <mturk@13f79535-47bb-0310-9956-ffa450edef68> | 2009-02-19 10:57:12 +0000 |
---|---|---|
committer | mturk <mturk@13f79535-47bb-0310-9956-ffa450edef68> | 2009-02-19 10:57:12 +0000 |
commit | 780df73984965700d6e90efc44979838d34ee66a (patch) | |
tree | c3d68cee5a766fb43cd0e3bd67f9633101200cc1 /file_io | |
parent | e1ac80932e537de19ac1640d0341e4e82bf1a2af (diff) | |
download | libapr-780df73984965700d6e90efc44979838d34ee66a.tar.gz |
On busy systems the accept can be delayed, so use the select and wait untill fully connected
git-svn-id: http://svn.apache.org/repos/asf/apr/apr/trunk@745813 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'file_io')
-rw-r--r-- | file_io/win32/pipe.c | 24 |
1 files changed, 21 insertions, 3 deletions
diff --git a/file_io/win32/pipe.c b/file_io/win32/pipe.c index 4ee629d9f..5812fa452 100644 --- a/file_io/win32/pipe.c +++ b/file_io/win32/pipe.c @@ -229,8 +229,9 @@ APR_DECLARE(apr_status_t) apr_os_pipe_put(apr_file_t **file, static apr_status_t create_socket_pipe(SOCKET *rd, SOCKET *wr) { static int id = 0; - + FD_SET rs; SOCKET ls; + struct timeval socktm; struct sockaddr_in pa; struct sockaddr_in la; struct sockaddr_in ca; @@ -290,10 +291,27 @@ static apr_status_t create_socket_pipe(SOCKET *rd, SOCKET *wr) goto cleanup; } for (;;) { + int ns; /* Listening socket is nonblocking by now. - * The accept must create the socket - * immediatelly because we connected already. + * The accept should create the socket + * immediatelly because we are connected already. + * However on buys systems this can take a while + * until winsock gets a chance to handle the events. */ + FD_ZERO(&rs); + FD_SET(ls, &rs); + + socktm.tv_sec = 1; + socktm.tv_usec = 0; + if ((ns = select(0, &rs, NULL, NULL, &socktm)) == SOCKET_ERROR) { + /* Accept still not signaled */ + Sleep(100); + continue; + } + if (ns == 0) { + /* No connections in the last second */ + continue; + } if ((*rd = accept(ls, (SOCKADDR *)&ca, &lc)) == INVALID_SOCKET) { rv = apr_get_netos_error(); goto cleanup; |