Return-Path: Delivered-To: apmail-apr-dev-archive@apr.apache.org Received: (qmail 44058 invoked by uid 500); 2 Jan 2002 19:28:26 -0000 Mailing-List: contact dev-help@apr.apache.org; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: Delivered-To: mailing list dev@apr.apache.org Received: (qmail 44047 invoked from network); 2 Jan 2002 19:28:26 -0000 Message-Id: X-Mailer: Novell GroupWise Internet Agent 6.0.1 Date: Wed, 02 Jan 2002 12:30:25 -0700 From: "Brad Nicholes" To: Subject: [PATCH] Win32/NetWare sockets.c Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=_FCA1FEC4.35542E44" X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N This is a MIME message. If you are reading this text, you may want to consider changing to a mail reader or gateway that understands how to properly handle MIME multipart messages. --=_FCA1FEC4.35542E44 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Content-Disposition: inline Oops, wrong list. Resent to the APR list >>> BNICHOLES@novell.com Wednesday, January 02, 2002 12:25:33 PM >>> Any feedback would be appreciated. If it looks OK then I will go ahead and check it in. Brad >>> "William A. Rowe, Jr." 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" To: 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 > --=_FCA1FEC4.35542E44 Content-Type: text/plain Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="sockets.c.txt" --- sockets.c Wed Dec 19 14:55:41 2001 +++ d:\tempapache\apr\network_io\win32\sockets.c Tue Dec 11 09:24:02 2001 @@ -226,26 +226,20 @@ 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); - memcpy (&(*new)->remote_addr->sa, &sa, salen); + (*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(); + } *(*new)->local_addr = *sock->local_addr; /* The above assignment just overwrote the pool entry. Setting the local_addr --=_FCA1FEC4.35542E44--