]> granicus.if.org Git - apache/commitdiff
Not sure what I was thinking, but this clarifies the logic for nbytes >
authorChuck Murcko <chuck@apache.org>
Fri, 13 Apr 2001 17:46:54 +0000 (17:46 +0000)
committerChuck Murcko <chuck@apache.org>
Fri, 13 Apr 2001 17:46:54 +0000 (17:46 +0000)
sizeof(buffer) towards the end of proxy_connect.c

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@88849 13f79535-47bb-0310-9956-ffa450edef68

modules/proxy/proxy_connect.c

index 8db5f3ae53f10c6f27eda004193100058c216c0c..d79b09728d69ea4d6d5106c905ec2d54c3c485e4 100644 (file)
@@ -106,7 +106,7 @@ int ap_proxy_connect_handler(request_rec *r, char *url,
     apr_socket_t *sock;
     apr_status_t err, rv;
     char buffer[HUGE_STRING_LEN];
-    int i;
+    int i, o;
     apr_size_t nbytes;
 
     apr_pollfd_t *pollfd;
@@ -326,14 +326,15 @@ int ap_proxy_connect_handler(request_rec *r, char *url,
                              "proxy: CONNECT: sock was set");*/
                 nbytes = sizeof(buffer);
                 if (apr_recv(sock, buffer, &nbytes) == APR_SUCCESS) {
-                    int o = 0;
-                    while(nbytes)
+                    o = 0;
+                    i = nbytes;
+                    while(i > 0)
                     {
+                        nbytes = i;
                        if (apr_send(r->connection->client_socket, buffer + o, &nbytes) != APR_SUCCESS)
                            break;
-                        i = nbytes;
-                        o += i;
-                        nbytes -= i;
+                        o += nbytes;
+                        i -= nbytes;
                     }
                 }
                 else
@@ -349,14 +350,15 @@ int ap_proxy_connect_handler(request_rec *r, char *url,
                              "proxy: CONNECT: client was set");*/
                 nbytes = sizeof(buffer);
                 if (apr_recv(r->connection->client_socket, buffer, &nbytes) == APR_SUCCESS) {
-                    int o = 0;
-                    while(nbytes)
+                    o = 0;
+                    i = nbytes;
+                    while(i > 0)
                     {
+                       nbytes = i;
                        if (apr_send(sock, buffer + o, &nbytes) != APR_SUCCESS)
                            break;
-                        i = nbytes;
-                        o += i;
-                        nbytes -= i;
+                        o += nbytes;
+                        i -= nbytes;
                     }
                 }
                 else