You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by wr...@apache.org on 2007/12/07 19:43:29 UTC

svn commit: r602175 - /httpd/mod_ftp/trunk/modules/ftp/ftp_commands.c

Author: wrowe
Date: Fri Dec  7 10:43:28 2007
New Revision: 602175

URL: http://svn.apache.org/viewvc?rev=602175&view=rev
Log:
This shouldn't be necessary, but segfaults on live servers just
are no fun.  APR's bug is that it fails to lookup, for example,
127.0.0.1 INET6 address although that is what we stored for the
local connection.  A small patch to apr lets us resolve these
addresses, but in the meantime, provide some diagnostics.


Modified:
    httpd/mod_ftp/trunk/modules/ftp/ftp_commands.c

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=602175&r1=602174&r2=602175&view=diff
==============================================================================
--- httpd/mod_ftp/trunk/modules/ftp/ftp_commands.c (original)
+++ httpd/mod_ftp/trunk/modules/ftp/ftp_commands.c Fri Dec  7 10:43:28 2007
@@ -1767,6 +1767,13 @@
        ) {
         apr_sockaddr_info_get(&sa, c->local_ip, family,
                               local_port, 0, c->pool);
+        if (!sa) {
+            ap_log_rerror(APLOG_MARK, APLOG_WARNING, rv, r,
+                          "Couldn't resolve explicit local socket address"
+                          " (apr or socket stack bug?)  Retrying");
+            apr_sockaddr_info_get(&sa, NULL, family,
+                                  local_port, 0, c->pool);
+        }
     }
     else {
         /* If the family differs, it's difficult to map the EPRT origin IP */
@@ -1774,6 +1781,13 @@
                               local_port, 0, c->pool);
     }
 
+    if (!sa) {
+        ap_log_rerror(APLOG_MARK, APLOG_ERR, rv, r,
+                      "Couldn't resolve local socket address"
+                      " (apr or socket stack bug?)  Giving up");
+        return FTP_REPLY_CANNOT_OPEN_DATACONN;
+    }
+
     apr_socket_opt_set(s, APR_SO_REUSEADDR, 1);
     rv = apr_socket_bind(s, sa);
 
@@ -1923,11 +1937,26 @@
     if (c->local_addr->family == APR_INET) {
         apr_sockaddr_info_get(&sa, c->local_ip, APR_INET,
                               local_port, 0, c->pool);
+        if (!sa) {
+            ap_log_rerror(APLOG_MARK, APLOG_WARNING, rv, r,
+                          "Couldn't resolve explicit local socket address"
+                          " (apr or socket stack bug?)  Retrying");
+            apr_sockaddr_info_get(&sa, NULL, APR_INET,
+                                  local_port, 0, c->pool);
+        }
     }
     else {
         apr_sockaddr_info_get(&sa, NULL, APR_INET,
                               local_port, 0, c->pool);
     }
+
+    if (!sa) {
+        ap_log_rerror(APLOG_MARK, APLOG_ERR, rv, r,
+                      "Couldn't resolve local socket address"
+                      " (apr or socket stack bug?)  Giving up");
+        return FTP_REPLY_CANNOT_OPEN_DATACONN;
+    }
+
     apr_socket_opt_set(s, APR_SO_REUSEADDR, 1);
     rv = apr_socket_bind(s, sa);