Hi,

While arranging the code of the recent 2.1-dev proxy enhancements to get CONNECT working I have noted that CONNECT loops endless when the client closes the connection. Find enclosed a patch than fixes the problem.

Cheers

Jean-Frederic
Index: proxy_connect.c
===================================================================
RCS file: /home/cvspublic/httpd-2.0/modules/proxy/proxy_connect.c,v
retrieving revision 1.68
diff -u -r1.68 proxy_connect.c
--- proxy_connect.c     13 Aug 2004 23:16:50 -0000      1.68
+++ proxy_connect.c     16 Aug 2004 12:05:38 -0000
@@ -292,8 +292,10 @@
             ap_log_rerror(APLOG_MARK, APLOG_ERR, rv, r, "proxy: CONNECT: error 
apr_poll()");
             return HTTP_INTERNAL_SERVER_ERROR;
         }
-/*     ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, r->server,
-                     "proxy: CONNECT: woke from select(), i=%d", pollcnt);*/
+#ifdef DEBUGGING
+        ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, r->server,
+                     "proxy: CONNECT: woke from select(), i=%d", pollcnt);
+#endif
 
         for (i = 0; i < pollcnt; i++) {
             const apr_pollfd_t *cur = &signalled[i];
@@ -301,10 +303,13 @@
             if (cur->desc.s == sock) {
                 pollevent = cur->rtnevents;
                 if (pollevent & APR_POLLIN) {
-/*             ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, r->server,
-                             "proxy: CONNECT: sock was set");*/
+#ifdef DEBUGGING
+                    ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, r->server,
+                                 "proxy: CONNECT: sock was set");
+#endif
                     nbytes = sizeof(buffer);
-                    if (apr_socket_recv(sock, buffer, &nbytes) == APR_SUCCESS) {
+                    rv = apr_socket_recv(sock, buffer, &nbytes);
+                    if (rv == APR_SUCCESS) {
                         o = 0;
                         i = nbytes;
                         while(i > 0)
@@ -316,7 +321,8 @@
      * if ((nbytes = ap_rwrite(buffer + o, nbytes, r)) < 0)
      * rbb
      */
-                            if (apr_socket_send(client_socket, buffer + o, &nbytes) 
!= APR_SUCCESS)
+                            rv = apr_socket_send(client_socket, buffer + o, &nbytes);
+                            if (rv != APR_SUCCESS)
                                 break;
                             o += nbytes;
                             i -= nbytes;
@@ -331,16 +337,24 @@
             else if (cur->desc.s == client_socket) {
                 pollevent = cur->rtnevents;
                 if (pollevent & APR_POLLIN) {
-/*             ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, r->server,
-                             "proxy: CONNECT: client was set");*/
+#ifdef DEBUGGING
+                    ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, r->server,
+                                 "proxy: CONNECT: client was set");
+#endif
                     nbytes = sizeof(buffer);
-                    if (apr_socket_recv(client_socket, buffer, &nbytes) == 
APR_SUCCESS) {
+                    rv = apr_socket_recv(client_socket, buffer, &nbytes);
+                    if (rv == APR_SUCCESS) {
                         o = 0;
                         i = nbytes;
+#ifdef DEBUGGING
+                        ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, r->server,
+                                     "proxy: CONNECT: read %d from client", i);
+#endif
                         while(i > 0)
                         {
                             nbytes = i;
-                            if (apr_socket_send(sock, buffer + o, &nbytes) != 
APR_SUCCESS)
+                            rv = apr_socket_send(sock, buffer + o, &nbytes);
+                            if (rv != APR_SUCCESS)
                                 break;
                             o += nbytes;
                             i -= nbytes;
@@ -354,6 +368,9 @@
             }
             else
                 break;
+        }
+        if (rv != APR_SUCCESS) {
+            break;
         }
     }
 

Reply via email to