httpd-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From wr...@apache.org
Subject svn commit: r603800 - in /httpd/mod_ftp/trunk: include/mod_ftp.h modules/ftp/ftp_commands.c modules/ftp/ftp_connection.c modules/ftp/ftp_data_connection.c
Date Thu, 13 Dec 2007 01:42:42 GMT
Author: wrowe
Date: Wed Dec 12 17:42:34 2007
New Revision: 603800

URL: http://svn.apache.org/viewvc?rev=603800&view=rev
Log:
Implement a single data connection-scoped data_pool, to prevent
memory exhaustion from repeated data connections.

(See also r603706, a premature commit of data_conn references.)

Modified:
    httpd/mod_ftp/trunk/include/mod_ftp.h
    httpd/mod_ftp/trunk/modules/ftp/ftp_commands.c
    httpd/mod_ftp/trunk/modules/ftp/ftp_connection.c
    httpd/mod_ftp/trunk/modules/ftp/ftp_data_connection.c

Modified: httpd/mod_ftp/trunk/include/mod_ftp.h
URL: http://svn.apache.org/viewvc/httpd/mod_ftp/trunk/include/mod_ftp.h?rev=603800&r1=603799&r2=603800&view=diff
==============================================================================
--- httpd/mod_ftp/trunk/include/mod_ftp.h (original)
+++ httpd/mod_ftp/trunk/include/mod_ftp.h Wed Dec 12 17:42:34 2007
@@ -301,6 +301,7 @@
     int filter_mask;          /* Filters required (CRLF, BYTERANGE, etc) */
 
     /* Data channel state */
+    apr_pool_t *data_pool;    /* Child of c->pool reset on every data cmd */
     int all_epsv;             /* EPSV ALL command issued (refuse all others) */
     apr_socket_t *csock;      /* The local data socket we connect/accept on */
     apr_socket_t *datasock;   /* The remote data socket we send/recv on */

Modified: httpd/mod_ftp/trunk/modules/ftp/ftp_commands.c
URL: http://svn.apache.org/viewvc/httpd/mod_ftp/trunk/modules/ftp/ftp_commands.c?rev=603800&r1=603799&r2=603800&view=diff
==============================================================================
--- httpd/mod_ftp/trunk/modules/ftp/ftp_commands.c (original)
+++ httpd/mod_ftp/trunk/modules/ftp/ftp_commands.c Wed Dec 12 17:42:34 2007
@@ -1951,12 +1951,12 @@
     }
 
     rv = apr_sockaddr_info_get(&fc->clientsa, ip_addr, APR_INET,
-                               port, 0, fc->datapool);
+                               port, 0, fc->data_pool);
 
     if (!fc->clientsa || rv) {
         ap_log_rerror(APLOG_MARK, APLOG_ERR, rv, r,
                       "Couldn't resolve remote socket address %s"
-                      " (apr or socket stack bug?)", ip_address);
+                      " (apr or socket stack bug?)", ip_addr);
         apr_socket_close(s);
         return FTP_REPLY_CANNOT_OPEN_DATACONN;
     }

Modified: httpd/mod_ftp/trunk/modules/ftp/ftp_connection.c
URL: http://svn.apache.org/viewvc/httpd/mod_ftp/trunk/modules/ftp/ftp_connection.c?rev=603800&r1=603799&r2=603800&view=diff
==============================================================================
--- httpd/mod_ftp/trunk/modules/ftp/ftp_connection.c (original)
+++ httpd/mod_ftp/trunk/modules/ftp/ftp_connection.c Wed Dec 12 17:42:34 2007
@@ -32,11 +32,11 @@
  *
  * Returns: nothing 
  */
-static void initialize_ftp_connection(conn_rec *c, ftp_connection *fc)
+static apr_status_t initialize_ftp_connection(conn_rec *c, ftp_connection *fc)
 {
     /* The ftp_connection structure is calloc'ed so only initalize
-     * the members that we need to. */
-
+     * the members that we need to.
+     */
     fc->connection       = c;
     fc->user             = "unknown";
     fc->auth             = FTP_AUTH_NONE;
@@ -44,9 +44,10 @@
     fc->cwd              = "/";
     fc->type             = TYPE_A;
     fc->passive_created  = -1;
-
     fc->orig_server      = c->base_server;
-    fc->cntlsock = ap_get_module_config(c->conn_config, &core_module);
+
+    fc->cntlsock  = ap_get_module_config(c->conn_config, &core_module);
+    return apr_pool_create(&fc->data_pool, c->pool);
 }
 
 /* ftp_ssl_init: Fakes a read on the SSL filters to force initialization.
@@ -104,7 +105,7 @@
     /* Check if a login message has been configured */
     if (fsc->banner_message) {
         if (fsc->banner_message_isfile) {
-            rv = ftp_show_file(c->output_filters, c->pool, 
+            rv = ftp_show_file(c->output_filters, fc->data_pool, 
                                FTP_REPLY_SERVICE_READY, fc, 
                                fsc->banner_message);
             if (rv != APR_SUCCESS) {
@@ -117,7 +118,7 @@
             ftp_message_generate(fc, fsc->banner_message,
                                  outbuf, sizeof(outbuf));
 
-            rv = ftp_reply(fc, c->output_filters, c->pool,
+            rv = ftp_reply(fc, c->output_filters, fc->data_pool,
                            FTP_REPLY_SERVICE_READY, 1, outbuf); 
 
             if (rv != APR_SUCCESS) {
@@ -126,7 +127,8 @@
         }
     }
 
-    rv = ftp_reply(fc, c->output_filters, c->pool, FTP_REPLY_SERVICE_READY, 0,
+    rv = ftp_reply(fc, c->output_filters, fc->data_pool,
+                   FTP_REPLY_SERVICE_READY, 0,
                    "%s FTP Server (%s) ready.",
                    c->base_server->server_hostname,
                    ap_get_server_version());
@@ -157,14 +159,19 @@
         ftp_get_module_config(c->base_server->module_config);
 
     if (!fsc->enabled) {
-        return DECLINED;
+        return OK;
     }
 
     /*
      * Allocate for FTP connection structure, and initialize 
      */
     fc = apr_pcalloc(c->pool, sizeof(*fc));
-    initialize_ftp_connection(c, fc);
+    if ((rv = initialize_ftp_connection(c, fc)) != APR_SUCCESS) {
+        /* Failure creating the data subpool */
+        ap_log_error(APLOG_MARK, APLOG_CRIT, rv, c->base_server,
+                     "Failure initializing FTP connection pool.");
+        return OK;
+    }
 
     /* Check for implicit security on the control connection */
     if (!fsc->implicit_ssl) {

Modified: httpd/mod_ftp/trunk/modules/ftp/ftp_data_connection.c
URL: http://svn.apache.org/viewvc/httpd/mod_ftp/trunk/modules/ftp/ftp_data_connection.c?rev=603800&r1=603799&r2=603800&view=diff
==============================================================================
--- httpd/mod_ftp/trunk/modules/ftp/ftp_data_connection.c (original)
+++ httpd/mod_ftp/trunk/modules/ftp/ftp_data_connection.c Wed Dec 12 17:42:34 2007
@@ -35,6 +35,7 @@
     }
     fc->clientsa = NULL;
     fc->passive_created = -1;
+    apr_pool_clear(fc->data_pool);
 }
 
 /*
@@ -109,7 +110,7 @@
         }
 
         /* activity on client socket, attempt an accept() */
-        rv = apr_socket_accept(&s, fc->csock, c->pool);
+        rv = apr_socket_accept(&s, fc->csock, fc->data_pool);
 
         res = apr_socket_close(fc->csock);
         fc->csock = NULL;
@@ -247,8 +248,9 @@
                 core_net_rec *net = f->ctx;
                 apr_bucket *e;
 
-                net->in_ctx = apr_pcalloc(f->c->pool, sizeof(*net->in_ctx));
-                net->in_ctx->b = apr_brigade_create(f->c->pool, f->c->bucket_alloc);
+                net->in_ctx = apr_pcalloc(fc->data_pool, sizeof(*net->in_ctx));
+                net->in_ctx->b = apr_brigade_create(fc->data_pool,
+                                                    f->c->bucket_alloc);
                 net->in_ctx->tmpbb = 
                     apr_brigade_create(net->in_ctx->b->p,
                                        net->in_ctx->b->bucket_alloc);



Mime
View raw message