Sorry, this one should be better.

>>> [EMAIL PROTECTED] Wednesday, January 02, 2002 12:35:48 PM >>>
Your patch has the wrong polarity (the code you are adding is marked
with '-' rather than
'+'). Please post the corrected patch and I'll look at it.

Bill

----- Original Message -----
From: "Brad Nicholes" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>; <[email protected]>;
<[EMAIL PROTECTED]>;
<[EMAIL PROTECTED]>
Sent: Wednesday, January 02, 2002 2:25 PM
Subject: [PATCH] Win32/NetWare sockets.c


> Any feedback would be appreciated.  If it looks OK then I will go
ahead
> and check it in.
>
> Brad
>
> >>> "William A. Rowe, Jr." <[EMAIL PROTECTED]> Wednesday, January
02,
> 2002 12:12:59 PM >>>
> I'll look at this this afternoon ... but Mr's Stoddard and Trawick
> have
> a wee bit of insight about Win32 Sockets API [much more than myself]
> and
> might be interested as well.
>
> Bill
>
> ----- Original Message -----
> From: "Brad Nicholes" <[EMAIL PROTECTED]>
> To: <[EMAIL PROTECTED]>
> Sent: Wednesday, January 02, 2002 10:37 AM
> Subject: Changes to sockets.c
>
>
> > Bill,
> >     Would you mind taking a quick look at this before I check it
in.
>
> > Basically I moved the call to accept() before allocating the
> > apr_socket_t structure so that I can do non-blocking accepts
without
> > chewing up a huge chunk of memory on WSAEWOULDBLOCK's.  No need to
> > allocate memory if it would have blocked anyway or recieved some
> other
> > error.  FYI, there may be other places where the APR functions
don't
> > accomodate a non-blocking scheme, but I haven't had the time to
look
> > into it yet.
> >
> > thanks,
> > Brad
> >
>

--- \tempapache\apr\network_io\win32\sockets.c  Tue Dec 11 09:24:02 2001
+++ sockets.c   Wed Dec 19 14:55:41 2001
@@ -226,20 +226,26 @@
 APR_DECLARE(apr_status_t) apr_accept(apr_socket_t **new, apr_socket_t *sock,
                                      apr_pool_t *p)
 {
+    SOCKET s;
+    struct sockaddr sa;
+    int salen = sizeof(sock->remote_addr->sa);
+
+    // Don't allocate the memory until after we call accept. This allows
+    //  us to work with nonblocking sockets.
+    s = accept(sock->sock, (struct sockaddr *)&sa, &salen);
+    if (s == INVALID_SOCKET) {
+        return apr_get_netos_error();
+    }
+
     alloc_socket(new, p);
     set_socket_vars(*new, sock->local_addr->sa.sin.sin_family, SOCK_STREAM);
 
     (*new)->timeout = -1;   
     (*new)->disconnected = 0;
 
+    (*new)->sock = s;
     (*new)->remote_addr->salen = sizeof((*new)->remote_addr->sa);
-    (*new)->sock = accept(sock->sock, 
-                          (struct sockaddr *)&(*new)->remote_addr->sa,
-                          &(*new)->remote_addr->salen);
-
-    if ((*new)->sock == INVALID_SOCKET) {
-        return apr_get_netos_error();
-    }
+    memcpy (&(*new)->remote_addr->sa, &sa, salen);
     *(*new)->local_addr = *sock->local_addr;
 
     /* The above assignment just overwrote the pool entry. Setting the 
local_addr 

Reply via email to