You are viewing a plain text version of this content. The canonical link for it is here.
Posted to announce@apache.org by Rodent of Unusual Size <Ke...@Golux.Com> on 2000/09/15 18:36:37 UTC

ApacheCon early-bird registration - Last Notice

This is the last message I'll send on this subject..

To-day, Friday 15 September 2000 (yes, I finally got it
right!) is the LAST DAY for early-bird registration for
the ApacheCon 2000 Europe conference to be held in London
on 23-25 October this year.  Registering during this period
gives you a £75 discount.  The early-bird period closes
at 17h00 (5 pm) this evening US Eastern Daylight Time (GMT -0500).

To register for the conference or find out more about registering,
go to

	http://ApacheCon.Com/2000/EU/html/registry.html

Thanks!
-- 
#ken    P-)}

Ken Coar                    <http://Golux.Com/coar/>
Apache Software Foundation  <http://www.apache.org/>
"Apache Server for Dummies" <http://Apache-Server.Com/>
"Apache Server Unleashed"   <http://ApacheUnleashed.Com/>

Re: [PATCH] win32/sockets.c - remove select in connect routine

Posted by Gregory Nicholls <gn...@level8.com>.
>

 OK this is different for Win32 (or NT at least). If the connect fails you can pick this up using the
except fd set.
If you find your socket in the write set, the connect (by definition) worked. I have no idea what'll
happen if you do another connect, I might experiment a bit and see if it can be made to work the way Unix
does.
    G.

>
>
> We don't know whether or not the connect was successful.  On Unix, it
> is normal to call connect() again once select() pops; the retcode from
> connect() tells us whether or not the connection was established.
>


Re: [PATCH] win32/sockets.c - remove select in connect routine

Posted by rb...@covalent.net.
> > See a previous note where I posted a version of canonerr.c for Win32 that has this and a few others
> > as well.
> 
> I'm not eager to mess with error codes, so I was testing with a
> minimal set of changes.  Besides, Ryan said he was going to handle
> your canonerr.c patch :)

I am looking at it, in time.  :-)  I kind of like OtherBill's solution
best though, so I may just do that this weekend.

Ryan
_______________________________________________________________________________
Ryan Bloom                        	rbb@apache.org
406 29th St.
San Francisco, CA 94131
-------------------------------------------------------------------------------


Re: [PATCH] win32/sockets.c - remove select in connect routine

Posted by Jeff Trawick <tr...@bellsouth.net>.
Gregory Nicholls <gn...@level8.com> writes:

> Jeff Trawick wrote:
> 
> > . I modified the client test program to wait for the connect to
> > complete, and then call apr_connect() again to find out what happened
> 
> This shouldn't be necessary. AFAIK when the socket is available for writing the connect is
> complete. What's
> the second call telling us ??

We don't know whether or not the connect was successful.  On Unix, it
is normal to call connect() again once select() pops; the retcode from
connect() tells us whether or not the connection was established.

> > . I modified (kludged) unix/canonerr.c to map WSAEWOULDBLOCK to
> > APR_EAGAIN; connect() on Win32 returns WSAEWOULDBLOCK in the
> > non-blocking case
> 
> See a previous note where I posted a version of canonerr.c for Win32 that has this and a few others
> as well.

I'm not eager to mess with error codes, so I was testing with a
minimal set of changes.  Besides, Ryan said he was going to handle
your canonerr.c patch :)

> > With my patch, the client test program is broken when it does a
> > non-blocking apr_connect() on Win32.  I try to use apr_poll() to find
> > out when the connect is done, but apr_poll() doesn't return when
> > the connect succeeds/fails.  Maybe I need to pass a different flag?
> > Maybe it just won't work this way on Win32?  This needs more
> > research.
> >
> > In your testing, what did you do to find out when the connect() is
> > done?  That is the missing piece.
> 
> Well all I did was issue a select() with that socket in the write set. I confess I didn't use the
> apr_poll() routine
> so perhaps there's something odd in there. I'll have a bit of a look at the poll routine and the
> client and see what pops up.

Good...  Google told me I could wait for the FD_EVENT event on the
socket to find out when the connect is done, but I don't see how that
fits into the apr_poll() abstraction.

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

Re: [PATCH] win32/sockets.c - remove select in connect routine

Posted by Gregory Nicholls <gn...@level8.com>.

Jeff Trawick wrote:

> Gregory Nicholls <gn...@level8.com> writes:
>
> >  This patch removes the select from the win32/sockets.c connect routine. It will now permit a
> > non-blocking connect.
>
> I started playing with your patch and ended up with the patch below.
>
> In my patch:
>
> . I modified your Win32 apr_connect() and the existing Unix
> apr_connect() to set some stuff before returning from apr_connect()
> after a non-blocking connect(); these may not be required as long as
> we force the app to call apr_connect() again after finding out that
> connect() is finished

Oh bugger ...  you're right. I had the local_port and local_interface stuff set in an earlier
version and forgot to
do it in the patch <sigh> mea culpa.

>
>
> . I modified the client test program to wait for the connect to
> complete, and then call apr_connect() again to find out what happened

This shouldn't be necessary. AFAIK when the socket is available for writing the connect is
complete. What's
the second call telling us ??

>
> . I modified (kludged) unix/canonerr.c to map WSAEWOULDBLOCK to
> APR_EAGAIN; connect() on Win32 returns WSAEWOULDBLOCK in the
> non-blocking case

See a previous note where I posted a version of canonerr.c for Win32 that has this and a few others
as well.

>
> With my patch, the client test program is broken when it does a
> non-blocking apr_connect() on Win32.  I try to use apr_poll() to find
> out when the connect is done, but apr_poll() doesn't return when
> the connect succeeds/fails.  Maybe I need to pass a different flag?
> Maybe it just won't work this way on Win32?  This needs more
> research.
>
> In your testing, what did you do to find out when the connect() is
> done?  That is the missing piece.

Well all I did was issue a select() with that socket in the write set. I confess I didn't use the
apr_poll() routine
so perhaps there's something odd in there. I'll have a bit of a look at the poll routine and the
client and see what pops up.
    G.



Re: [PATCH] win32/sockets.c - remove select in connect routine

Posted by Jeff Trawick <tr...@bellsouth.net>.
Gregory Nicholls <gn...@level8.com> writes:

>  This patch removes the select from the win32/sockets.c connect routine. It will now permit a
> non-blocking connect.

I started playing with your patch and ended up with the patch below.

In my patch:

. I modified your Win32 apr_connect() and the existing Unix
apr_connect() to set some stuff before returning from apr_connect()
after a non-blocking connect(); these may not be required as long as
we force the app to call apr_connect() again after finding out that
connect() is finished

. I modified the client test program to wait for the connect to
complete, and then call apr_connect() again to find out what happened

. I modified (kludged) unix/canonerr.c to map WSAEWOULDBLOCK to
APR_EAGAIN; connect() on Win32 returns WSAEWOULDBLOCK in the
non-blocking case

With my patch, the client test program is broken when it does a
non-blocking apr_connect() on Win32.  I try to use apr_poll() to find
out when the connect is done, but apr_poll() doesn't return when
the connect succeeds/fails.  Maybe I need to pass a different flag?
Maybe it just won't work this way on Win32?  This needs more
research.

In your testing, what did you do to find out when the connect() is
done?  That is the missing piece.

Index: misc/unix/canonerr.c
===================================================================
RCS file: /cvs/apache/apache-2.0/src/lib/apr/misc/unix/canonerr.c,v
retrieving revision 1.5
diff -u -r1.5 canonerr.c
--- canonerr.c	2000/08/02 05:26:22	1.5
+++ canonerr.c	2000/09/20 16:01:45
@@ -63,6 +63,11 @@
         errcode = EAGAIN;
     }
 #endif
+#if defined(WIN32)
+    if (errcode == WSAEWOULDBLOCK) {
+        errcode = APR_EAGAIN;
+    }
+#endif
     return errcode;
 }
 
Index: network_io/unix/sockets.c
===================================================================
RCS file: /cvs/apache/apache-2.0/src/lib/apr/network_io/unix/sockets.c,v
retrieving revision 1.53
diff -u -r1.53 sockets.c
--- sockets.c	2000/08/06 06:07:22	1.53
+++ sockets.c	2000/09/20 16:01:45
@@ -209,24 +209,25 @@
 #endif
     }
 
-    if ((connect(sock->socketdes, (const struct sockaddr *)sock->remote_addr,
-        sock->addr_len) < 0) && (errno != EINPROGRESS)) {
-        return errno;
+    /* Fill out some info in apr_socket_t as if connect() will work. */
+    if (sock->local_addr->sin_port == 0) {
+        /* connect() got us an ephemeral port */
+        sock->local_port_unknown = 1;
     }
-    else {
-        if (sock->local_addr->sin_port == 0) {
-            /* connect() got us an ephemeral port */
-            sock->local_port_unknown = 1;
-        }
-        if (sock->local_addr->sin_addr.s_addr == 0) {
-            /* not bound to specific local interface; connect() had to assign
-             * one for the socket
-             */
-            sock->local_interface_unknown = 1;
-        }
+    if (sock->local_addr->sin_addr.s_addr == 0) {
+        /* not bound to specific local interface; connect() had to assign
+         * one for the socket
+         */
+        sock->local_interface_unknown = 1;
+    }
 #ifndef HAVE_POLL
-	sock->connected=1;
+    sock->connected = 1;
 #endif
+    if (connect(sock->socketdes, (const struct sockaddr *)sock->remote_addr,
+        sock->addr_len) < 0) {
+        return errno;
+    }
+    else {
         return APR_SUCCESS;
     }
 }
Index: network_io/win32/sockets.c
===================================================================
RCS file: /cvs/apache/apache-2.0/src/lib/apr/network_io/win32/sockets.c,v
retrieving revision 1.37
diff -u -r1.37 sockets.c
--- sockets.c	2000/08/06 06:07:24	1.37
+++ sockets.c	2000/09/20 16:01:45
@@ -215,8 +215,6 @@
 apr_status_t apr_connect(apr_socket_t *sock, char *hostname)
 {
     struct hostent *hp;
-    int lasterror;
-    fd_set temp;
 
     if ((sock->sock == INVALID_SOCKET) || (!sock->local_addr)) {
         return APR_ENOTSOCK;
@@ -239,26 +237,17 @@
     
     sock->remote_addr->sin_family = AF_INET;
 
-    if (connect(sock->sock, (const struct sockaddr *)sock->remote_addr, 
-                sock->addr_len) == SOCKET_ERROR) {
-        lasterror = WSAGetLastError();
-        if (lasterror != WSAEWOULDBLOCK) {
-            return lasterror;
-        }
-        /* wait for the connect to complete */
-        FD_ZERO(&temp);
-        FD_SET(sock->sock, &temp);
-        if (select(sock->sock+1, NULL, &temp, NULL, NULL) == SOCKET_ERROR) {
-            return WSAGetLastError();
-        }
-    }
-    /* connect was OK .. amazing */
+    /* Fill out some info in apr_socket_t as if connect() will work. */
     if (sock->local_addr->sin_port == 0) {
         sock->local_port_unknown = 1;
     }
     if (sock->local_addr->sin_addr.s_addr == 0) {
         /* must be using free-range port */
         sock->local_interface_unknown = 1;
+    }
+    if (connect(sock->sock, (const struct sockaddr *)sock->remote_addr, 
+                sock->addr_len) == SOCKET_ERROR) {
+        return WSAGetLastError();
     }
     return APR_SUCCESS;
 }
Index: test/client.c
===================================================================
RCS file: /cvs/apache/apache-2.0/src/lib/apr/test/client.c,v
retrieving revision 1.14
diff -u -r1.14 client.c
--- client.c	2000/08/06 06:07:28	1.14
+++ client.c	2000/09/20 16:01:46
@@ -52,6 +52,7 @@
  * <http://www.apache.org/>.
  */
 
+#include <assert.h>
 #include <stdlib.h>
 #include "apr_network_io.h"
 #include "apr_errno.h"
@@ -127,7 +128,9 @@
 
     stat = apr_connect(sock, dest);
 
-    if (stat != APR_SUCCESS) {
+    if (stat != APR_SUCCESS && 
+        !(apr_canonical_error(stat) == APR_EINPROGRESS ||
+            apr_canonical_error(stat) == APR_EAGAIN)) {
         apr_close_socket(sock);
         fprintf(stderr, "Could not connect: %s (%d)\n", 
 		apr_strerror(stat, msgbuf, sizeof(msgbuf)), stat);
@@ -135,6 +138,35 @@
         exit(-1);
     }
     fprintf(stdout, "OK\n");
+
+    if (stat != APR_SUCCESS) {
+        apr_pollfd_t *pfd;
+        apr_int32_t nsocks;
+
+        assert(read_timeout == -1);
+        fprintf(stdout, "\tClient:  Waiting for connect to complete (or fail).....");
+        pfd = NULL;
+        stat = apr_setup_poll(&pfd, 1, context);
+        assert(!stat);
+        stat = apr_add_poll_socket(pfd, sock, APR_POLLOUT);
+        assert(!stat);
+        nsocks = 1;
+        stat = apr_poll(pfd, &nsocks, -1);
+        assert(!stat);
+        assert(nsocks == 1);
+        fprintf(stdout, "OK\n");
+        fprintf(stdout, "\tClient:  Checking result of connect....");
+        stat = apr_connect(sock, dest);
+        if (stat != APR_SUCCESS) {
+            apr_close_socket(sock);
+            fprintf(stdout, "Failed: %s (%d)\n", 
+                    apr_strerror(stat, msgbuf, sizeof(msgbuf)), stat);
+            exit(-1);
+        }
+        else {
+            fprintf(stdout, "OK\n");
+        }
+    }
 
     apr_get_remote_ipaddr(&remote_ipaddr, sock);
     apr_get_remote_port(&remote_port, sock);

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

[PATCH] win32/sockets.c - remove select in connect routine

Posted by Gregory Nicholls <gn...@level8.com>.
 This patch removes the select from the win32/sockets.c connect routine. It will now permit a
non-blocking connect.

---------------- cut here -------------------------------------------
Index: sockets.c
===================================================================
RCS file: /home/cvspublic/apache-2.0/src/lib/apr/network_io/win32/sockets.c,v
retrieving revision 1.37
diff -u -d -p -r1.37 sockets.c
--- sockets.c   2000/08/06 06:07:24     1.37
+++ sockets.c   2000/09/15 20:09:43
@@ -215,8 +215,6 @@ apr_status_t apr_accept(apr_socket_t **n
 apr_status_t apr_connect(apr_socket_t *sock, char *hostname)
 {
     struct hostent *hp;
-    int lasterror;
-    fd_set temp;

     if ((sock->sock == INVALID_SOCKET) || (!sock->local_addr)) {
         return APR_ENOTSOCK;
@@ -241,16 +239,7 @@ apr_status_t apr_connect(apr_socket_t *s

     if (connect(sock->sock, (const struct sockaddr *)sock->remote_addr,
                 sock->addr_len) == SOCKET_ERROR) {
-        lasterror = WSAGetLastError();
-        if (lasterror != WSAEWOULDBLOCK) {
-            return lasterror;
-        }
-        /* wait for the connect to complete */
-        FD_ZERO(&temp);
-        FD_SET(sock->sock, &temp);
-        if (select(sock->sock+1, NULL, &temp, NULL, NULL) == SOCKET_ERROR) {
-            return WSAGetLastError();
-        }
+      return WSAGetLastError();
     }
     /* connect was OK .. amazing */
     if (sock->local_addr->sin_port == 0) {




canonerr.c for WINNT

Posted by Gregory Nicholls <gn...@level8.com>.
Here's a version of canonerr.c for Win32. I'm not smart enough with CVS to get it to format a
patch for a module it doesn't already have so I'm posting it here. It probably needs some change
in the Win32 build as well. I placed in in apr/misc/win32 on my box.
    It basically changes some of the common Winsock codes over to APR ones.

        G.

-------- cut here ---------------------------
/* ====================================================================
 * The Apache Software License, Version 1.1
 *
 * Copyright (c) 2000 The Apache Software Foundation.  All rights
 * reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 *
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 *
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in
 *    the documentation and/or other materials provided with the
 *    distribution.
 *
 * 3. The end-user documentation included with the redistribution,
 *    if any, must include the following acknowledgment:
 *       "This product includes software developed by the
 *        Apache Software Foundation (http://www.apache.org/)."
 *    Alternately, this acknowledgment may appear in the software itself,
 *    if and wherever such third-party acknowledgments normally appear.
 *
 * 4. The names "Apache" and "Apache Software Foundation" must
 *    not be used to endorse or promote products derived from this
 *    software without prior written permission. For written
 *    permission, please contact apache@apache.org.
 *
 * 5. Products derived from this software may not be called "Apache",
 *    nor may "Apache" appear in their name, without prior written
 *    permission of the Apache Software Foundation.
 *
 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 * SUCH DAMAGE.
 * ====================================================================
 *
 * This software consists of voluntary contributions made by many
 * individuals on behalf of the Apache Software Foundation.  For more
 * information on the Apache Software Foundation, please see
 * <http://www.apache.org/>.
 */

#include "misc.h"

static int errmap[]={WSAEWOULDBLOCK,APR_EAGAIN,\
                     WSAEINTR,APR_EINTR,\
                     WSAENOTSOCK,APR_ENOTSOCK,\
                     WSAECONNREFUSED,APR_ECONNREFUSED,\
                     WSAEBADF,APR_EBADF,\
                     WSAEACCES,APR_EACCES\
                     -1,-1,\
                     };

int apr_canonical_error(apr_status_t errcode)
{
 int i;

 for(i=0; errmap[i] != -1; i++)
  {
   if(errmap[i]==errcode) return(errmap[i+1]);
   i++;
  }
 return(errcode);
}



Re: Patch question ??

Posted by Gregory Nicholls <gn...@level8.com>.
 Hmm. It looked lie a couple of the other things I changed made it into that source module.
That's why I'm asking. Otherwise I'll post a new patch and see if anyone objects.
    G.

Jeff Trawick wrote:

> Gregory Nicholls <gn...@level8.com> writes:
>
> >  Back on July 26th I submitted a patch for win32/sockets.c that modified the
> > connect to remove the explicit select wait. This was so I could use a
> > non-blocking connect(). Now the select is back in the latest version so
> > obviously it was there for a reason. Could someone tell me what the reason
> > is please ?
> >     Thanks,
> >         G.
>
> I don't think that code was ever removed.  See
>
> http://www.apache.org/websrc/viewcvs.cgi/apache-2.0/src/lib/apr/network_io/win32/sockets.c
>
> Revisions 1.34 and 1.35 put in most of your code.
>
> I agree that the select shouldn't be there.  The Unix code looks a lot
> better.
> --
> Jeff Trawick | trawick@ibm.net | PGP public key at web site:
>      http://www.geocities.com/SiliconValley/Park/9289/
>           Born in Roswell... married an alien...


Re: Patch question ??

Posted by Jeff Trawick <tr...@bellsouth.net>.
Gregory Nicholls <gn...@level8.com> writes:

>  Back on July 26th I submitted a patch for win32/sockets.c that modified the
> connect to remove the explicit select wait. This was so I could use a
> non-blocking connect(). Now the select is back in the latest version so
> obviously it was there for a reason. Could someone tell me what the reason
> is please ?
>     Thanks,
>         G.

I don't think that code was ever removed.  See 

http://www.apache.org/websrc/viewcvs.cgi/apache-2.0/src/lib/apr/network_io/win32/sockets.c

Revisions 1.34 and 1.35 put in most of your code.

I agree that the select shouldn't be there.  The Unix code looks a lot
better.
-- 
Jeff Trawick | trawick@ibm.net | PGP public key at web site:
     http://www.geocities.com/SiliconValley/Park/9289/
          Born in Roswell... married an alien...

Patch question ??

Posted by Gregory Nicholls <gn...@level8.com>.
 Back on July 26th I submitted a patch for win32/sockets.c that modified the
connect to remove the explicit select wait. This was so I could use a
non-blocking connect(). Now the select is back in the latest version so
obviously it was there for a reason. Could someone tell me what the reason
is please ?
    Thanks,
        G.


Re: ApacheCon early-bird registration - Last Notice

Posted by David Reid <da...@jetnet.co.uk>.
Ken,

As I've had no luck contacting them directly can you register me and let 
me know how to pay using the ASF special rate?  Thanks.

Off to EDI tonight!

david

"I never get involved in my own life, it's way
too complicated."