httpd-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From r..@apache.org
Subject cvs commit: httpd-2.0/server core.c
Date Wed, 14 Nov 2001 21:18:47 GMT
rbb         01/11/14 13:18:47

  Modified:    modules/proxy proxy_connect.c proxy_ftp.c proxy_http.c
               server   core.c
  Log:
  Get the proxy module compiling again.  This is a hack to get past the
  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.
  
  Revision  Changes    Path
  1.51      +21 -5     httpd-2.0/modules/proxy/proxy_connect.c
  
  Index: proxy_connect.c
  ===================================================================
  RCS file: /home/cvs/httpd-2.0/modules/proxy/proxy_connect.c,v
  retrieving revision 1.50
  retrieving revision 1.51
  diff -u -r1.50 -r1.51
  --- proxy_connect.c	2001/08/20 16:49:29	1.50
  +++ proxy_connect.c	2001/11/14 21:18:46	1.51
  @@ -128,6 +128,7 @@
       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 @@
   		     "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 @@
       }
   
       /* 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 @@
                       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 @@
   		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)
  
  
  
  1.82      +7 -5      httpd-2.0/modules/proxy/proxy_ftp.c
  
  Index: proxy_ftp.c
  ===================================================================
  RCS file: /home/cvs/httpd-2.0/modules/proxy/proxy_ftp.c,v
  retrieving revision 1.81
  retrieving revision 1.82
  diff -u -r1.81 -r1.82
  --- proxy_ftp.c	2001/10/08 19:25:35	1.81
  +++ proxy_ftp.c	2001/11/14 21:18:46	1.82
  @@ -556,6 +556,7 @@
       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 @@
   	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 @@
       }
   
       /* 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 @@
       /* 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 @@
       }
   
       /* 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 @@
   	}
       }
       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 @@
       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;
   }
  
  
  
  1.109     +5 -3      httpd-2.0/modules/proxy/proxy_http.c
  
  Index: proxy_http.c
  ===================================================================
  RCS file: /home/cvs/httpd-2.0/modules/proxy/proxy_http.c,v
  retrieving revision 1.108
  retrieving revision 1.109
  diff -u -r1.108 -r1.109
  --- proxy_http.c	2001/11/12 03:23:12	1.108
  +++ proxy_http.c	2001/11/14 21:18:47	1.109
  @@ -276,6 +276,7 @@
                                                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 @@
        */
       /* 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 @@
                            " 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 @@
   
           /* 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 @@
                        "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() 
  
  
  
  1.96      +1 -0      httpd-2.0/server/core.c
  
  Index: core.c
  ===================================================================
  RCS file: /home/cvs/httpd-2.0/server/core.c,v
  retrieving revision 1.95
  retrieving revision 1.96
  diff -u -r1.95 -r1.96
  --- core.c	2001/11/14 00:38:16	1.95
  +++ core.c	2001/11/14 21:18:47	1.96
  @@ -3324,6 +3324,7 @@
    
       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;
  
  
  

Mime
View raw message