]> granicus.if.org Git - apache/commitdiff
Get the proxy module compiling again. This is a hack to get past the
authorRyan Bloom <rbb@apache.org>
Wed, 14 Nov 2001 21:18:47 +0000 (21:18 +0000)
committerRyan Bloom <rbb@apache.org>
Wed, 14 Nov 2001 21:18:47 +0000 (21:18 +0000)
current compiler errors.  Basically, the core now puts the socket
in the conn_rec->conn_config vector.  The proxy grabs that socket and
uses it where it used to use the client_socket field from the conn_rec.
Long-term, all of the direct socket communication needs to be removed,
and this should go through a filter stack.  Short-term, this gets the
proxy working again.

I have tested http and connect, but I haven't looked at the FTP proxy,
although it does compile now.

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

modules/proxy/proxy_connect.c
modules/proxy/proxy_ftp.c
modules/proxy/proxy_http.c
server/core.c

index 218b33265f7711d236841ece1fa8f85bac61612d..2b4df9f968ee75fa0ffa8b732d717bbc590b25f8 100644 (file)
@@ -128,6 +128,7 @@ int ap_proxy_connect_handler(request_rec *r, proxy_server_conf *conf,
     apr_status_t err, rv;
     apr_size_t i, o, nbytes;
     char buffer[HUGE_STRING_LEN];
+    apr_socket_t *client_socket = ap_get_module_config(r->connection->conn_config, &core_module);
 
     apr_pollfd_t *pollfd;
     apr_int32_t pollcnt;
@@ -305,10 +306,19 @@ int ap_proxy_connect_handler(request_rec *r, proxy_server_conf *conf,
                     "proxy: CONNECT: Returning 200 OK Status");
         nbytes = apr_snprintf(buffer, sizeof(buffer),
                              "HTTP/1.0 200 Connection Established" CRLF);
-        apr_send(r->connection->client_socket, buffer, &nbytes);
+        apr_send(client_socket, buffer, &nbytes);
         nbytes = apr_snprintf(buffer, sizeof(buffer),
                              "Proxy-agent: %s" CRLF CRLF, ap_get_server_version());
+#if 0
+        /* This is safer code, but it doesn't work yet.  I'm leaving it 
+         * here so that I can fix it later.
+         */
         apr_send(r->connection->client_socket, buffer, &nbytes);
+        r->status = HTTP_OK;
+        r->header_only = 1;
+        apr_table_set(r->headers_out, "Proxy-agent: %s", ap_get_server_version());
+        ap_rflush(r);
+#endif
     }
 
     ap_log_error(APLOG_MARK, APLOG_DEBUG|APLOG_NOERRNO, 0, r->server,
@@ -331,7 +341,7 @@ int ap_proxy_connect_handler(request_rec *r, proxy_server_conf *conf,
     }
 
     /* Add client side to the poll */
-    apr_poll_socket_add(pollfd, r->connection->client_socket, APR_POLLIN);
+    apr_poll_socket_add(pollfd, client_socket, APR_POLLIN);
 
     /* Add the server side to the poll */
     apr_poll_socket_add(pollfd, sock, APR_POLLIN);
@@ -359,7 +369,13 @@ int ap_proxy_connect_handler(request_rec *r, proxy_server_conf *conf,
                     while(i > 0)
                     {
                         nbytes = i;
-                       if (apr_send(r->connection->client_socket, buffer + o, &nbytes) != APR_SUCCESS)
+    /* This is just plain wrong.  No module should ever write directly
+     * to the client.  For now, this works, but this is high on my list of
+     * things to fix.  The correct line is:
+     * if ((nbytes = ap_rwrite(buffer + o, nbytes, r)) < 0)
+     * rbb
+     */
+                        if (apr_send(client_socket, buffer + o, &nbytes) != APR_SUCCESS)
                            break;
                         o += nbytes;
                         i -= nbytes;
@@ -372,12 +388,12 @@ int ap_proxy_connect_handler(request_rec *r, proxy_server_conf *conf,
                break;
 
 
-            apr_poll_revents_get(&pollevent, r->connection->client_socket, pollfd);
+            apr_poll_revents_get(&pollevent, client_socket, pollfd);
             if (pollevent & APR_POLLIN) {
 /*             ap_log_error(APLOG_MARK, APLOG_DEBUG|APLOG_NOERRNO, 0, r->server,
                              "proxy: CONNECT: client was set");*/
                 nbytes = sizeof(buffer);
-                if (apr_recv(r->connection->client_socket, buffer, &nbytes) == APR_SUCCESS) {
+                if (apr_recv(client_socket, buffer, &nbytes) == APR_SUCCESS) {
                     o = 0;
                     i = nbytes;
                     while(i > 0)
index 1c505809e16429529a24cfb905c1fbfd77a7d2fb..7748a3d587bd1a791bdebcddbe726287b527e3ad 100644 (file)
@@ -556,6 +556,7 @@ int ap_proxy_ftp_handler(request_rec *r, proxy_server_conf *conf,
     int one = 1;
     char *size = NULL;
     apr_off_t readbytes = -1;
+    apr_socket_t *origin_sock;
 
     /* stuff for PASV mode */
     int connect = 0, use_port = 0;
@@ -584,6 +585,7 @@ int ap_proxy_ftp_handler(request_rec *r, proxy_server_conf *conf,
        backend->port = 0;
        ap_set_module_config(c->conn_config, &proxy_ftp_module, backend);
     }
+    origin_sock = ap_get_module_config(backend->connection->conn_config, &core_module);
 
 
     /* 
@@ -745,7 +747,7 @@ int ap_proxy_ftp_handler(request_rec *r, proxy_server_conf *conf,
     }
 
     /* the socket is now open, create a new connection */
-    origin = ap_new_connection(p, r->server, sock, r->connection->id);
+    origin = ap_run_create_connection(p, r->server, sock, r->connection->id);
     if (!origin) {
        /* the peer reset the connection already; ap_new_connection() 
         * closed the socket */
@@ -757,7 +759,7 @@ int ap_proxy_ftp_handler(request_rec *r, proxy_server_conf *conf,
     /* if a keepalive connection is floating around, close it first! */
     /* we might support ftp keepalives later, but not now... */
     if (backend->connection) {
-       apr_socket_close(backend->connection->client_socket);
+       apr_socket_close(origin_sock);
        backend->connection = NULL;
     }
 
@@ -1548,7 +1550,7 @@ int ap_proxy_ftp_handler(request_rec *r, proxy_server_conf *conf,
     }
 
     /* the transfer socket is now open, create a new connection */
-    remote = ap_new_connection(p, r->server, remote_sock, r->connection->id);
+    remote = ap_run_create_connection(p, r->server, remote_sock, r->connection->id);
     if (!remote) {
        /* the peer reset the connection already; ap_new_connection() 
         * closed the socket */
@@ -1597,7 +1599,7 @@ int ap_proxy_ftp_handler(request_rec *r, proxy_server_conf *conf,
        }
     }
     ap_flush_conn(remote);
-    apr_socket_close(remote->client_socket);
+    apr_socket_close(remote_sock);
     ap_log_error(APLOG_MARK, APLOG_DEBUG|APLOG_NOERRNO, 0, r->server,
                 "proxy: FTP: Closing Data connection.");
     rc = ftp_getrc_msg(origin, cbb, buffer, sizeof(buffer));
@@ -1632,7 +1634,7 @@ int ap_proxy_ftp_handler(request_rec *r, proxy_server_conf *conf,
     ap_log_error(APLOG_MARK, APLOG_DEBUG|APLOG_NOERRNO, 0, r->server,
                  "proxy: FTP: %d %s", rc, buffer);
     ap_flush_conn(origin);
-    apr_socket_close(origin->client_socket);
+    apr_socket_close(origin_sock);
     apr_brigade_destroy(bb);
     return OK;
 }
index 40659e6fbe510e84131189851247ed0a78e7c385..e74dfd19e546b0d96e201347074b08fbbf18f555 100644 (file)
@@ -276,6 +276,7 @@ apr_status_t ap_proxy_http_create_connection(apr_pool_t *p, request_rec *r,
                                              const char *proxyname) {
     int failed=0, new=0;
     apr_status_t rv;
+    apr_socket_t *client_socket;
 
     /* We have determined who to connect to. Now make the connection, supporting
      * a KeepAlive connection.
@@ -290,6 +291,7 @@ apr_status_t ap_proxy_http_create_connection(apr_pool_t *p, request_rec *r,
      */
     /* see memory note above */
     if (backend->connection) {
+        client_socket = ap_get_module_config(backend->connection->conn_config, &core_module);;
         if ((backend->connection->id == c->id) &&
             (backend->port == p_conn->port) &&
             (backend->hostname) &&
@@ -302,7 +304,7 @@ apr_status_t ap_proxy_http_create_connection(apr_pool_t *p, request_rec *r,
                          " changed (close old socket (%s/%s, %d/%d))", 
                          p_conn->name, backend->hostname, p_conn->port,
                          backend->port);
-            apr_socket_close(backend->connection->client_socket);
+            apr_socket_close(client_socket);
             backend->connection = NULL;
         }
     }
@@ -317,7 +319,7 @@ apr_status_t ap_proxy_http_create_connection(apr_pool_t *p, request_rec *r,
 
         /* use previous keepalive socket */
         *origin = backend->connection;
-        p_conn->sock = (*origin)->client_socket;
+        p_conn->sock = client_socket;
         new = 0;
 
         /* reset the connection filters */
@@ -412,7 +414,7 @@ apr_status_t ap_proxy_http_create_connection(apr_pool_t *p, request_rec *r,
                      "proxy: socket is connected");
 
         /* the socket is now open, create a new backend server connection */
-        *origin = ap_new_connection(c->pool, r->server, p_conn->sock,
+        *origin = ap_run_create_connection(c->pool, r->server, p_conn->sock,
                                    r->connection->id);
         if (!origin) {
         /* the peer reset the connection already; ap_new_connection() 
index 1209cf545acfc49a59301e7a596e07fe11e65051..8b37a810df7947d3ba28aad5e4df4cae83715f91 100644 (file)
@@ -3324,6 +3324,7 @@ static conn_rec *core_create_conn(apr_pool_t *ptrans, server_rec *server,
  
     apr_pool_cleanup_register(ptrans, net, ap_lingering_close, apr_pool_cleanup_null);
  
+    ap_set_module_config(net->c->conn_config, &core_module, csd);
     ap_add_input_filter("CORE_IN", net, NULL, net->c);
     ap_add_output_filter("CORE", net, NULL, net->c);
     return net->c;