You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@httpd.apache.org by Rodent of Unusual Size <Ke...@Golux.Com> on 2000/07/26 22:47:52 UTC

Re: cvs commit: apache-2.0/src/modules/mpm/mpmt Makefile.in config.m4 mpm.h mpm_default.h mpmt.c scoreboard.c scoreboard.h

rbb@locus.apache.org wrote:
> 
>   REmove the mpmt MPM.

Um, didn't you just add it a couple of weeks ago?  I'm caught
up in the mail, and I don't see what caused this action..  Not
that I object.
-- 
#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: Bizarre problem - Patch

Posted by Gregory Nicholls <gn...@level8.com>.
 Well after a bit of sleep it occurs to me that maybe ap_recv() is supposed to handle
setting the len to 0 if there's an error. Sure enough this is the way Unix works. Win32
however ..<sigh>. Since I'm still working with my patch applied I fixed this in the
patched code. I'm not sure of the protocols for resubmitting this for review so here it
is again.

--------------cut here ----------------------------------------
Index: networkio.h
===================================================================
RCS file: /home/cvspublic/apache-2.0/src/lib/apr/network_io/win32/networkio.h,v
retrieving revision 1.11
diff -u -d -b -r1.11 networkio.h
--- networkio.h 2000/07/06 15:13:25 1.11
+++ networkio.h 2000/07/27 12:56:43
@@ -66,6 +66,8 @@
     size_t addr_len;
     ap_interval_time_t timeout;
     ap_int32_t disconnected;
+    int local_port_unknown;
+    int local_interface_unknown;
 };

 struct ap_pollfd_t {
Index: sendrecv.c
===================================================================
RCS file: /home/cvspublic/apache-2.0/src/lib/apr/network_io/win32/sendrecv.c,v
retrieving revision 1.21
diff -u -d -b -r1.21 sendrecv.c
--- sendrecv.c 2000/07/06 15:13:25 1.21
+++ sendrecv.c 2000/07/27 12:56:44
@@ -95,6 +95,7 @@
     rv = WSARecv(sock->sock, &wsaData, 1, &dwBytes, &flags, NULL, NULL);
     if (rv == SOCKET_ERROR) {
         lasterror = WSAGetLastError();
+        *len=0;
         return lasterror;
     }

Index: sockaddr.c
===================================================================
RCS file: /home/cvspublic/apache-2.0/src/lib/apr/network_io/win32/sockaddr.c,v
retrieving revision 1.9
diff -u -d -b -r1.9 sockaddr.c
--- sockaddr.c 2000/07/25 00:42:13 1.9
+++ sockaddr.c 2000/07/27 12:56:45
@@ -58,6 +58,21 @@
 #include "apr_strings.h"
 #include <string.h>

+static ap_status_t get_local_addr(ap_socket_t *sock)
+{
+    size_t namelen = sizeof(*sock->local_addr);
+
+    if (getsockname(sock->sock, (struct sockaddr *)sock->local_addr,
+                    &namelen) < 0) {
+        return WSAGetLastError();
+    }
+    else {
+        sock->local_port_unknown = sock->local_interface_unknown = 0;
+        return APR_SUCCESS;
+    }
+}
+
+

 ap_status_t ap_set_local_port(ap_socket_t *sock, ap_uint32_t port)
 {
@@ -77,6 +92,14 @@

 ap_status_t ap_get_local_port(ap_uint32_t *port, ap_socket_t *sock)
 {
+    if (sock->local_port_unknown) {
+        ap_status_t rv = get_local_addr(sock);
+
+        if (rv != APR_SUCCESS) {
+            return rv;
+        }
+    }
+
     *port = ntohs(sock->local_addr->sin_port);
     return APR_SUCCESS;
 }
@@ -131,6 +154,14 @@

 ap_status_t ap_get_local_ipaddr(char **addr, ap_socket_t *sock)
 {
+    if (sock->local_interface_unknown) {
+        ap_status_t rv = get_local_addr(sock);
+
+        if (rv != APR_SUCCESS) {
+            return rv;
+        }
+    }
+
     *addr = ap_pstrdup(sock->cntxt, inet_ntoa(sock->local_addr->sin_addr));
     return APR_SUCCESS;
 }
@@ -146,6 +177,14 @@

 ap_status_t ap_get_local_name(struct sockaddr_in **name, ap_socket_t *sock)
 {
+    if (sock->local_port_unknown || sock->local_interface_unknown) {
+        ap_status_t rv = get_local_addr(sock);
+
+        if (rv != APR_SUCCESS) {
+            return rv;
+        }
+    }
+
     *name = sock->local_addr;
     return APR_SUCCESS;
 }
Index: sockets.c
===================================================================
RCS file: /home/cvspublic/apache-2.0/src/lib/apr/network_io/win32/sockets.c,v
retrieving revision 1.34
diff -u -d -b -r1.34 sockets.c
--- sockets.c 2000/07/25 15:50:52 1.34
+++ sockets.c 2000/07/27 12:56:46
@@ -150,8 +150,12 @@
     if (bind(sock->sock, (struct sockaddr *)sock->local_addr, sock->addr_len) == -1) {

         return WSAGetLastError();
     }
-    else
+    else {
+        if (sock->local_addr->sin_port == 0) {
+            sock->local_port_unknown = 1; /* ephemeral port */
+        }
         return APR_SUCCESS;
+    }
 }

 ap_status_t ap_listen(ap_socket_t *sock, ap_int32_t backlog)
@@ -185,6 +189,24 @@
         return WSAGetLastError();
     }

+    *(*new)->local_addr = *sock->local_addr;
+
+    if (sock->local_port_unknown) {
+        /* not likely for a listening socket, but theoretically possible :) */
+        (*new)->local_port_unknown = 1;
+    }
+
+    if (sock->local_interface_unknown ||
+        sock->local_addr->sin_addr.s_addr == 0) {
+        /* If the interface address inside the listening socket's local_addr wasn't
+         * up-to-date, we don't know local interface of the connected socket either.
+         *
+         * If the listening socket was not bound to a specific interface, we
+         * don't know the local_addr of the connected socket.
+         */
+        (*new)->local_interface_unknown = 1;
+    }
+
     ap_register_cleanup((*new)->cntxt, (void *)(*new),
                         socket_cleanup, ap_null_cleanup);
     return APR_SUCCESS;
@@ -218,20 +240,25 @@
     sock->remote_addr->sin_family = AF_INET;

     if (connect(sock->sock, (const struct sockaddr *)sock->remote_addr,
-                sock->addr_len) == 0) {
-        return APR_SUCCESS;
-    }
-    else {
+                sock->addr_len) == SOCKET_ERROR) {
         lasterror = WSAGetLastError();
-        if (lasterror == WSAEWOULDBLOCK) {
+        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) == 1) {
-                return APR_SUCCESS;
+        if (select(sock->sock+1, NULL, &temp, NULL, NULL) == SOCKET_ERROR) {
+                return WSAGetLastError();
             }
         }
-        return lasterror;
+/* connect was OK .. amazing */
+    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;
+    }
+    return APR_SUCCESS;
 }

 ap_status_t ap_get_socketdata(void **data, const char *key, ap_socket_t *socket)
@@ -273,6 +300,7 @@
         (*sock)->timeout = -1;
         (*sock)->disconnected = 0;
     }
+    (*sock)->local_port_unknown = (*sock)->local_interface_unknown = 1;
     (*sock)->sock = *thesock;
     return APR_SUCCESS;
 }



Bizarre problem

Posted by Gregory Nicholls <gn...@level8.com>.
 Hiya,
    I'm running into a bizarre problem where I'm issuing a request and the request
is being processed twice. After some hunting it seems that the problem (if it's
actually a problem) lies in the socket_read function in iol_socket.c.
    To cut a long story short, this guy is setting the connection->client->incnt
value to 4096 (his input buffer size) independent of whether any data is received.
The actual receive returned a WOODBLOCK(which is how my head currently feels). This
caused everyone to go back and use the same buffers they had before, hence
processing my request twice. He craps out after the second cycle because although
he thinks he has data left over based on the remaining length, it's garbage.
    I don't really feel qualified to touch this code so if someone could tell me if
I'm right on this I'd be grateful.
    G.


Re: cvs commit: apache-2.0/src/modules/mpm/mpmt Makefile.in config.m4 mpm.h mpm_default.h mpmt.c scoreboard.c scoreboard.h

Posted by rb...@covalent.net.
On Wed, 26 Jul 2000, Rodent of Unusual Size wrote:

> rbb@locus.apache.org wrote:
> > 
> >   REmove the mpmt MPM.
> 
> Um, didn't you just add it a couple of weeks ago?  I'm caught
> up in the mail, and I don't see what caused this action..  Not
> that I object.

What caused this was enough people saying no to it.  I don't have the time
to devote to cleaning it, it wasn't getting tested, and everybody else on
the list seems to dislike the general idea.

Ryan

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