You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by yl...@apache.org on 2014/06/16 22:26:25 UTC

svn commit: r1602989 - in /httpd/httpd/trunk: CHANGES include/ap_mmn.h modules/proxy/mod_proxy.h modules/proxy/mod_proxy_fdpass.c modules/proxy/proxy_util.c

Author: ylavic
Date: Mon Jun 16 20:26:24 2014
New Revision: 1602989

URL: http://svn.apache.org/r1602989
Log:
mod_proxy: Don't limit the size of the connectable Unix Domain Socket paths.
Since connect() to UDS path is used at several places, introduce
ap_proxy_connect_uds() in proxy_util.

Modified:
    httpd/httpd/trunk/CHANGES
    httpd/httpd/trunk/include/ap_mmn.h
    httpd/httpd/trunk/modules/proxy/mod_proxy.h
    httpd/httpd/trunk/modules/proxy/mod_proxy_fdpass.c
    httpd/httpd/trunk/modules/proxy/proxy_util.c

Modified: httpd/httpd/trunk/CHANGES
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/CHANGES?rev=1602989&r1=1602988&r2=1602989&view=diff
==============================================================================
--- httpd/httpd/trunk/CHANGES [utf-8] (original)
+++ httpd/httpd/trunk/CHANGES [utf-8] Mon Jun 16 20:26:24 2014
@@ -1,6 +1,9 @@
                                                          -*- coding: utf-8 -*-
 Changes with Apache 2.5.0
 
+  *) mod_proxy: Don't limit the size of the connectable Unix Domain Socket
+     paths. [Christophe Jaillet, Yann Ylavic]
+
   *) mod_ssl: dump SSL IO/state for the write side of the connection(s),
      like reads (level TRACE4). [Yann Ylavic]
 
@@ -31,7 +34,7 @@ Changes with Apache 2.5.0
      PR 56286 [Micha Lenk <micha lenk info>]
 
   *) mod_proxy_fdpass: Fix computation of the size of 'struct sockaddr_un'
-     when passed to 'connec()'.
+     when passed to 'connect()'.
      [Graham Dumpleton <grahamd apache org>]
 
   *) mod_socache_shmcb: Correct counting of expirations for status display.

Modified: httpd/httpd/trunk/include/ap_mmn.h
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/include/ap_mmn.h?rev=1602989&r1=1602988&r2=1602989&view=diff
==============================================================================
--- httpd/httpd/trunk/include/ap_mmn.h (original)
+++ httpd/httpd/trunk/include/ap_mmn.h Mon Jun 16 20:26:24 2014
@@ -461,6 +461,7 @@
                            Changes 3rd argument's type of
                            ap_mpm_register_socket_callback and 
                            ap_mpm_register_socket_callback_timeout.
+ * 20140611.1 (2.5.0-dev)  Add ap_proxy_connect_uds().
  */
 
 #define MODULE_MAGIC_COOKIE 0x41503235UL /* "AP25" */
@@ -468,7 +469,7 @@
 #ifndef MODULE_MAGIC_NUMBER_MAJOR
 #define MODULE_MAGIC_NUMBER_MAJOR 20140611
 #endif
-#define MODULE_MAGIC_NUMBER_MINOR 0                  /* 0...n */
+#define MODULE_MAGIC_NUMBER_MINOR 1                  /* 0...n */
 
 /**
  * Determine if the server's current MODULE_MAGIC_NUMBER is at least a

Modified: httpd/httpd/trunk/modules/proxy/mod_proxy.h
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/proxy/mod_proxy.h?rev=1602989&r1=1602988&r2=1602989&view=diff
==============================================================================
--- httpd/httpd/trunk/modules/proxy/mod_proxy.h (original)
+++ httpd/httpd/trunk/modules/proxy/mod_proxy.h Mon Jun 16 20:26:24 2014
@@ -874,6 +874,17 @@ PROXY_DECLARE(int) ap_proxy_connect_back
                                             proxy_conn_rec *conn,
                                             proxy_worker *worker,
                                             server_rec *s);
+
+/**
+ * Make a connection to a Unix Domain Socket (UDS) path
+ * @param sock     UDS to connect
+ * @param uds_path UDS path to connect to
+ * @param p        pool to make the sock addr
+ * @return         APR_SUCCESS or error status
+ */
+PROXY_DECLARE(apr_status_t) ap_proxy_connect_uds(apr_socket_t *sock,
+                                                 const char *uds_path,
+                                                 apr_pool_t *p);
 /**
  * Make a connection record for backend connection
  * @param proxy_function calling proxy scheme (http, ajp, ...)

Modified: httpd/httpd/trunk/modules/proxy/mod_proxy_fdpass.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/proxy/mod_proxy_fdpass.c?rev=1602989&r1=1602988&r2=1602989&view=diff
==============================================================================
--- httpd/httpd/trunk/modules/proxy/mod_proxy_fdpass.c (original)
+++ httpd/httpd/trunk/modules/proxy/mod_proxy_fdpass.c Mon Jun 16 20:26:24 2014
@@ -24,12 +24,6 @@
 #error This module only works on unix platforms with the correct OS support
 #endif
 
-#include "apr_version.h"
-#if APR_MAJOR_VERSION < 2
-/* for apr_wait_for_io_or_timeout */
-#include "apr_support.h"
-#endif
-
 #include "mod_proxy_fdpass.h"
 
 module AP_MODULE_DECLARE_DATA proxy_fdpass_module;
@@ -54,56 +48,10 @@ static int proxy_fdpass_canon(request_re
     return OK;
 }
 
-/* TODO: In APR 2.x: Extend apr_sockaddr_t to possibly be a path !!! */
-/* XXX: The same function exists in proxy_util.c */
-static apr_status_t socket_connect_un(apr_socket_t *sock,
-                                      struct sockaddr_un *sa)
-{
-    apr_status_t rv;
-    apr_os_sock_t rawsock;
-    apr_interval_time_t t;
-
-    rv = apr_os_sock_get(&rawsock, sock);
-    if (rv != APR_SUCCESS) {
-        return rv;
-    }
-
-    rv = apr_socket_timeout_get(sock, &t);
-    if (rv != APR_SUCCESS) {
-        return rv;
-    }
-
-    do {
-        const socklen_t addrlen = APR_OFFSETOF(struct sockaddr_un, sun_path)
-                                  + strlen(sa->sun_path) + 1;
-        rv = connect(rawsock, (struct sockaddr*)sa, addrlen);
-    } while (rv == -1 && errno == EINTR);
-
-    if ((rv == -1) && (errno == EINPROGRESS || errno == EALREADY)
-        && (t > 0)) {
-#if APR_MAJOR_VERSION < 2
-        rv = apr_wait_for_io_or_timeout(NULL, sock, 0);
-#else
-        rv = apr_socket_wait(sock, APR_WAIT_WRITE);
-#endif
-
-        if (rv != APR_SUCCESS) {
-            return rv;
-        }
-    }
-
-    if (rv == -1 && errno != EISCONN) {
-        return errno;
-    }
-
-    return APR_SUCCESS;
-}
-
 static apr_status_t get_socket_from_path(apr_pool_t *p,
                                          const char* path,
                                          apr_socket_t **out_sock)
 {
-    struct sockaddr_un sa;
     apr_socket_t *s;
     apr_status_t rv;
     *out_sock = NULL;
@@ -114,10 +62,7 @@ static apr_status_t get_socket_from_path
         return rv;
     }
 
-    sa.sun_family = AF_UNIX;
-    apr_cpystrn(sa.sun_path, path, sizeof(sa.sun_path));
-
-    rv = socket_connect_un(s, &sa);
+    rv = ap_proxy_connect_uds(s, path, p);
     if (rv != APR_SUCCESS) {
         return rv;
     }

Modified: httpd/httpd/trunk/modules/proxy/proxy_util.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/proxy/proxy_util.c?rev=1602989&r1=1602988&r2=1602989&view=diff
==============================================================================
--- httpd/httpd/trunk/modules/proxy/proxy_util.c (original)
+++ httpd/httpd/trunk/modules/proxy/proxy_util.c Mon Jun 16 20:26:24 2014
@@ -2550,13 +2550,16 @@ static apr_status_t send_http_connect(pr
 
 
 #if APR_HAVE_SYS_UN_H
-/* lifted from mod_proxy_fdpass.c; tweaked addrlen in connect() call */
-static apr_status_t socket_connect_un(apr_socket_t *sock,
-                                      struct sockaddr_un *sa)
+/* TODO: In APR 2.x: Extend apr_sockaddr_t to possibly be a path !!! */
+PROXY_DECLARE(apr_status_t) ap_proxy_connect_uds(apr_socket_t *sock,
+                                                 const char *uds_path,
+                                                 apr_pool_t *p)
 {
     apr_status_t rv;
     apr_os_sock_t rawsock;
     apr_interval_time_t t;
+    struct sockaddr_un *sa;
+    apr_socklen_t addrlen, pathlen;
 
     rv = apr_os_sock_get(&rawsock, sock);
     if (rv != APR_SUCCESS) {
@@ -2568,29 +2571,30 @@ static apr_status_t socket_connect_un(ap
         return rv;
     }
 
+    pathlen = strlen(uds_path);
+    /* copy the UDS path (including NUL) to the sockaddr_un */
+    addrlen = APR_OFFSETOF(struct sockaddr_un, sun_path) + pathlen;
+    sa = (struct sockaddr_un *)apr_palloc(p, addrlen + 1);
+    memcpy(sa->sun_path, uds_path, pathlen + 1);
+    sa->sun_family = AF_UNIX;
+
     do {
-        const socklen_t addrlen = APR_OFFSETOF(struct sockaddr_un, sun_path)
-                                  + strlen(sa->sun_path) + 1;
         rv = connect(rawsock, (struct sockaddr*)sa, addrlen);
-    } while (rv == -1 && errno == EINTR);
+    } while (rv == -1 && (rv = errno) == EINTR);
 
-    if ((rv == -1) && (errno == EINPROGRESS || errno == EALREADY)
-        && (t > 0)) {
+    if (rv && rv != EISCONN) {
+        if ((rv == EINPROGRESS || rv == EALREADY) && (t > 0))  {
 #if APR_MAJOR_VERSION < 2
-        rv = apr_wait_for_io_or_timeout(NULL, sock, 0);
+            rv = apr_wait_for_io_or_timeout(NULL, sock, 0);
 #else
-        rv = apr_socket_wait(sock, APR_WAIT_WRITE);
+            rv = apr_socket_wait(sock, APR_WAIT_WRITE);
 #endif
-
+        }
         if (rv != APR_SUCCESS) {
             return rv;
         }
     }
 
-    if (rv == -1 && errno != EISCONN) {
-        return errno;
-    }
-
     return APR_SUCCESS;
 }
 #endif
@@ -2623,8 +2627,6 @@ PROXY_DECLARE(int) ap_proxy_connect_back
 #if APR_HAVE_SYS_UN_H
         if (conn->uds_path)
         {
-            struct sockaddr_un sa;
-
             rv = apr_socket_create(&newsock, AF_UNIX, SOCK_STREAM, 0,
                                    conn->scpool);
             if (rv != APR_SUCCESS) {
@@ -2638,10 +2640,7 @@ PROXY_DECLARE(int) ap_proxy_connect_back
             }
             conn->connection = NULL;
 
-            sa.sun_family = AF_UNIX;
-            apr_cpystrn(sa.sun_path, conn->uds_path, sizeof(sa.sun_path));
-
-            rv = socket_connect_un(newsock, &sa);
+            rv = ap_proxy_connect_uds(newsock, conn->uds_path, conn->scpool);
             if (rv != APR_SUCCESS) {
                 apr_socket_close(newsock);
                 ap_log_error(APLOG_MARK, APLOG_ERR, rv, s, APLOGNO(02454)



Re: svn commit: r1602989 - in /httpd/httpd/trunk: CHANGES include/ap_mmn.h modules/proxy/mod_proxy.h modules/proxy/mod_proxy_fdpass.c modules/proxy/proxy_util.c

Posted by Jeff Trawick <tr...@gmail.com>.
On Thu, Jun 19, 2014 at 1:39 PM, Yann Ylavic <yl...@gmail.com> wrote:

> On Thu, Jun 19, 2014 at 6:36 PM, Jeff Trawick <tr...@gmail.com> wrote:
> > On Mon, Jun 16, 2014 at 4:26 PM, <yl...@apache.org> wrote:
> >>
> >> Author: ylavic
> >> Date: Mon Jun 16 20:26:24 2014
> >> New Revision: 1602989
> >>
> >> URL: http://svn.apache.org/r1602989
> >> Log:
> >> mod_proxy: Don't limit the size of the connectable Unix Domain Socket
> >> paths.
> >> Since connect() to UDS path is used at several places, introduce
> >> ap_proxy_connect_uds() in proxy_util.
> >>
> >
> > mod_authnz_fcgi could use something like this when adding Unix socket
> > support...  (so maybe a core API?)  Maybe I'll get a chance to experiment
> > before this gets merged to the 2.4.x branch.
> >
> > It seems weird that proxy_fdpass's original implementation of the
> function
> > had the timeout handling logic, but the module did not set a timeout for
> the
> > socket (bad).  I guess that should be fixed in proxy_fdpass.
>
> I first wanted to add some core helpers and use them in mod_cgid too
> (didn't notice mod_authnz_fcgi was concerned with its APR_UNSPEC).
> But the timeout handling difference made me limit that to
> ap_proxy_connect_uds() only (and as a result put the connect in the
> function too)...
>
> The ideal would be to do that in APR though (where the code looks
> buggy too), and then use the apr_sockaddr_t where needed in httpd.
> Actually I'm working on a that APR patch, however what if APR is
> "fixed" on that point, do we still need the workaround in httpd for
> the ones using an older APR lib that used to work (eg. with mod_cgid)?
>

IMO 2.4.x should keep compatibility with APR 1.5.x for quite a while.
 (Event already requires 1.5.x.)  Hopefully there will be a period of time
which isn't so short when a lot of people that want to try 2.4.latest can
use distro-provided support libraries.

-- 
Born in Roswell... married an alien...
http://emptyhammock.com/
http://edjective.org/

Re: svn commit: r1602989 - in /httpd/httpd/trunk: CHANGES include/ap_mmn.h modules/proxy/mod_proxy.h modules/proxy/mod_proxy_fdpass.c modules/proxy/proxy_util.c

Posted by Yann Ylavic <yl...@gmail.com>.
On Thu, Jun 19, 2014 at 6:36 PM, Jeff Trawick <tr...@gmail.com> wrote:
> On Mon, Jun 16, 2014 at 4:26 PM, <yl...@apache.org> wrote:
>>
>> Author: ylavic
>> Date: Mon Jun 16 20:26:24 2014
>> New Revision: 1602989
>>
>> URL: http://svn.apache.org/r1602989
>> Log:
>> mod_proxy: Don't limit the size of the connectable Unix Domain Socket
>> paths.
>> Since connect() to UDS path is used at several places, introduce
>> ap_proxy_connect_uds() in proxy_util.
>>
>
> mod_authnz_fcgi could use something like this when adding Unix socket
> support...  (so maybe a core API?)  Maybe I'll get a chance to experiment
> before this gets merged to the 2.4.x branch.
>
> It seems weird that proxy_fdpass's original implementation of the function
> had the timeout handling logic, but the module did not set a timeout for the
> socket (bad).  I guess that should be fixed in proxy_fdpass.

I first wanted to add some core helpers and use them in mod_cgid too
(didn't notice mod_authnz_fcgi was concerned with its APR_UNSPEC).
But the timeout handling difference made me limit that to
ap_proxy_connect_uds() only (and as a result put the connect in the
function too)...

The ideal would be to do that in APR though (where the code looks
buggy too), and then use the apr_sockaddr_t where needed in httpd.
Actually I'm working on a that APR patch, however what if APR is
"fixed" on that point, do we still need the workaround in httpd for
the ones using an older APR lib that used to work (eg. with mod_cgid)?

Re: svn commit: r1602989 - in /httpd/httpd/trunk: CHANGES include/ap_mmn.h modules/proxy/mod_proxy.h modules/proxy/mod_proxy_fdpass.c modules/proxy/proxy_util.c

Posted by Jeff Trawick <tr...@gmail.com>.
On Mon, Jun 16, 2014 at 4:26 PM, <yl...@apache.org> wrote:

> Author: ylavic
> Date: Mon Jun 16 20:26:24 2014
> New Revision: 1602989
>
> URL: http://svn.apache.org/r1602989
> Log:
> mod_proxy: Don't limit the size of the connectable Unix Domain Socket
> paths.
> Since connect() to UDS path is used at several places, introduce
> ap_proxy_connect_uds() in proxy_util.
>
>
mod_authnz_fcgi could use something like this when adding Unix socket
support...  (so maybe a core API?)  Maybe I'll get a chance to experiment
before this gets merged to the 2.4.x branch.

It seems weird that proxy_fdpass's original implementation of the function
had the timeout handling logic, but the module did not set a timeout for
the socket (bad).  I guess that should be fixed in proxy_fdpass.




> Modified:
>     httpd/httpd/trunk/CHANGES
>     httpd/httpd/trunk/include/ap_mmn.h
>     httpd/httpd/trunk/modules/proxy/mod_proxy.h
>     httpd/httpd/trunk/modules/proxy/mod_proxy_fdpass.c
>     httpd/httpd/trunk/modules/proxy/proxy_util.c
>
> Modified: httpd/httpd/trunk/CHANGES
> URL:
> http://svn.apache.org/viewvc/httpd/httpd/trunk/CHANGES?rev=1602989&r1=1602988&r2=1602989&view=diff
>
> ==============================================================================
> --- httpd/httpd/trunk/CHANGES [utf-8] (original)
> +++ httpd/httpd/trunk/CHANGES [utf-8] Mon Jun 16 20:26:24 2014
> @@ -1,6 +1,9 @@
>                                                           -*- coding:
> utf-8 -*-
>  Changes with Apache 2.5.0
>
> +  *) mod_proxy: Don't limit the size of the connectable Unix Domain Socket
> +     paths. [Christophe Jaillet, Yann Ylavic]
> +
>    *) mod_ssl: dump SSL IO/state for the write side of the connection(s),
>       like reads (level TRACE4). [Yann Ylavic]
>
> @@ -31,7 +34,7 @@ Changes with Apache 2.5.0
>       PR 56286 [Micha Lenk <micha lenk info>]
>
>    *) mod_proxy_fdpass: Fix computation of the size of 'struct sockaddr_un'
> -     when passed to 'connec()'.
> +     when passed to 'connect()'.
>       [Graham Dumpleton <grahamd apache org>]
>
>    *) mod_socache_shmcb: Correct counting of expirations for status
> display.
>
> Modified: httpd/httpd/trunk/include/ap_mmn.h
> URL:
> http://svn.apache.org/viewvc/httpd/httpd/trunk/include/ap_mmn.h?rev=1602989&r1=1602988&r2=1602989&view=diff
>
> ==============================================================================
> --- httpd/httpd/trunk/include/ap_mmn.h (original)
> +++ httpd/httpd/trunk/include/ap_mmn.h Mon Jun 16 20:26:24 2014
> @@ -461,6 +461,7 @@
>                             Changes 3rd argument's type of
>                             ap_mpm_register_socket_callback and
>                             ap_mpm_register_socket_callback_timeout.
> + * 20140611.1 (2.5.0-dev)  Add ap_proxy_connect_uds().
>   */
>
>  #define MODULE_MAGIC_COOKIE 0x41503235UL /* "AP25" */
> @@ -468,7 +469,7 @@
>  #ifndef MODULE_MAGIC_NUMBER_MAJOR
>  #define MODULE_MAGIC_NUMBER_MAJOR 20140611
>  #endif
> -#define MODULE_MAGIC_NUMBER_MINOR 0                  /* 0...n */
> +#define MODULE_MAGIC_NUMBER_MINOR 1                  /* 0...n */
>
>  /**
>   * Determine if the server's current MODULE_MAGIC_NUMBER is at least a
>
> Modified: httpd/httpd/trunk/modules/proxy/mod_proxy.h
> URL:
> http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/proxy/mod_proxy.h?rev=1602989&r1=1602988&r2=1602989&view=diff
>
> ==============================================================================
> --- httpd/httpd/trunk/modules/proxy/mod_proxy.h (original)
> +++ httpd/httpd/trunk/modules/proxy/mod_proxy.h Mon Jun 16 20:26:24 2014
> @@ -874,6 +874,17 @@ PROXY_DECLARE(int) ap_proxy_connect_back
>                                              proxy_conn_rec *conn,
>                                              proxy_worker *worker,
>                                              server_rec *s);
> +
> +/**
> + * Make a connection to a Unix Domain Socket (UDS) path
> + * @param sock     UDS to connect
> + * @param uds_path UDS path to connect to
> + * @param p        pool to make the sock addr
> + * @return         APR_SUCCESS or error status
> + */
> +PROXY_DECLARE(apr_status_t) ap_proxy_connect_uds(apr_socket_t *sock,
> +                                                 const char *uds_path,
> +                                                 apr_pool_t *p);
>  /**
>   * Make a connection record for backend connection
>   * @param proxy_function calling proxy scheme (http, ajp, ...)
>
> Modified: httpd/httpd/trunk/modules/proxy/mod_proxy_fdpass.c
> URL:
> http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/proxy/mod_proxy_fdpass.c?rev=1602989&r1=1602988&r2=1602989&view=diff
>
> ==============================================================================
> --- httpd/httpd/trunk/modules/proxy/mod_proxy_fdpass.c (original)
> +++ httpd/httpd/trunk/modules/proxy/mod_proxy_fdpass.c Mon Jun 16 20:26:24
> 2014
> @@ -24,12 +24,6 @@
>  #error This module only works on unix platforms with the correct OS
> support
>  #endif
>
> -#include "apr_version.h"
> -#if APR_MAJOR_VERSION < 2
> -/* for apr_wait_for_io_or_timeout */
> -#include "apr_support.h"
> -#endif
> -
>  #include "mod_proxy_fdpass.h"
>
>  module AP_MODULE_DECLARE_DATA proxy_fdpass_module;
> @@ -54,56 +48,10 @@ static int proxy_fdpass_canon(request_re
>      return OK;
>  }
>
> -/* TODO: In APR 2.x: Extend apr_sockaddr_t to possibly be a path !!! */
> -/* XXX: The same function exists in proxy_util.c */
> -static apr_status_t socket_connect_un(apr_socket_t *sock,
> -                                      struct sockaddr_un *sa)
> -{
> -    apr_status_t rv;
> -    apr_os_sock_t rawsock;
> -    apr_interval_time_t t;
> -
> -    rv = apr_os_sock_get(&rawsock, sock);
> -    if (rv != APR_SUCCESS) {
> -        return rv;
> -    }
> -
> -    rv = apr_socket_timeout_get(sock, &t);
> -    if (rv != APR_SUCCESS) {
> -        return rv;
> -    }
> -
> -    do {
> -        const socklen_t addrlen = APR_OFFSETOF(struct sockaddr_un,
> sun_path)
> -                                  + strlen(sa->sun_path) + 1;
> -        rv = connect(rawsock, (struct sockaddr*)sa, addrlen);
> -    } while (rv == -1 && errno == EINTR);
> -
> -    if ((rv == -1) && (errno == EINPROGRESS || errno == EALREADY)
> -        && (t > 0)) {
> -#if APR_MAJOR_VERSION < 2
> -        rv = apr_wait_for_io_or_timeout(NULL, sock, 0);
> -#else
> -        rv = apr_socket_wait(sock, APR_WAIT_WRITE);
> -#endif
> -
> -        if (rv != APR_SUCCESS) {
> -            return rv;
> -        }
> -    }
> -
> -    if (rv == -1 && errno != EISCONN) {
> -        return errno;
> -    }
> -
> -    return APR_SUCCESS;
> -}
> -
>  static apr_status_t get_socket_from_path(apr_pool_t *p,
>                                           const char* path,
>                                           apr_socket_t **out_sock)
>  {
> -    struct sockaddr_un sa;
>      apr_socket_t *s;
>      apr_status_t rv;
>      *out_sock = NULL;
> @@ -114,10 +62,7 @@ static apr_status_t get_socket_from_path
>          return rv;
>      }
>
> -    sa.sun_family = AF_UNIX;
> -    apr_cpystrn(sa.sun_path, path, sizeof(sa.sun_path));
> -
> -    rv = socket_connect_un(s, &sa);
> +    rv = ap_proxy_connect_uds(s, path, p);
>      if (rv != APR_SUCCESS) {
>          return rv;
>      }
>
> Modified: httpd/httpd/trunk/modules/proxy/proxy_util.c
> URL:
> http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/proxy/proxy_util.c?rev=1602989&r1=1602988&r2=1602989&view=diff
>
> ==============================================================================
> --- httpd/httpd/trunk/modules/proxy/proxy_util.c (original)
> +++ httpd/httpd/trunk/modules/proxy/proxy_util.c Mon Jun 16 20:26:24 2014
> @@ -2550,13 +2550,16 @@ static apr_status_t send_http_connect(pr
>
>
>  #if APR_HAVE_SYS_UN_H
> -/* lifted from mod_proxy_fdpass.c; tweaked addrlen in connect() call */
> -static apr_status_t socket_connect_un(apr_socket_t *sock,
> -                                      struct sockaddr_un *sa)
> +/* TODO: In APR 2.x: Extend apr_sockaddr_t to possibly be a path !!! */
> +PROXY_DECLARE(apr_status_t) ap_proxy_connect_uds(apr_socket_t *sock,
> +                                                 const char *uds_path,
> +                                                 apr_pool_t *p)
>  {
>      apr_status_t rv;
>      apr_os_sock_t rawsock;
>      apr_interval_time_t t;
> +    struct sockaddr_un *sa;
> +    apr_socklen_t addrlen, pathlen;
>
>      rv = apr_os_sock_get(&rawsock, sock);
>      if (rv != APR_SUCCESS) {
> @@ -2568,29 +2571,30 @@ static apr_status_t socket_connect_un(ap
>          return rv;
>      }
>
> +    pathlen = strlen(uds_path);
> +    /* copy the UDS path (including NUL) to the sockaddr_un */
> +    addrlen = APR_OFFSETOF(struct sockaddr_un, sun_path) + pathlen;
> +    sa = (struct sockaddr_un *)apr_palloc(p, addrlen + 1);
> +    memcpy(sa->sun_path, uds_path, pathlen + 1);
> +    sa->sun_family = AF_UNIX;
> +
>      do {
> -        const socklen_t addrlen = APR_OFFSETOF(struct sockaddr_un,
> sun_path)
> -                                  + strlen(sa->sun_path) + 1;
>          rv = connect(rawsock, (struct sockaddr*)sa, addrlen);
> -    } while (rv == -1 && errno == EINTR);
> +    } while (rv == -1 && (rv = errno) == EINTR);
>
> -    if ((rv == -1) && (errno == EINPROGRESS || errno == EALREADY)
> -        && (t > 0)) {
> +    if (rv && rv != EISCONN) {
> +        if ((rv == EINPROGRESS || rv == EALREADY) && (t > 0))  {
>  #if APR_MAJOR_VERSION < 2
> -        rv = apr_wait_for_io_or_timeout(NULL, sock, 0);
> +            rv = apr_wait_for_io_or_timeout(NULL, sock, 0);
>  #else
> -        rv = apr_socket_wait(sock, APR_WAIT_WRITE);
> +            rv = apr_socket_wait(sock, APR_WAIT_WRITE);
>  #endif
> -
> +        }
>          if (rv != APR_SUCCESS) {
>              return rv;
>          }
>      }
>
> -    if (rv == -1 && errno != EISCONN) {
> -        return errno;
> -    }
> -
>      return APR_SUCCESS;
>  }
>  #endif
> @@ -2623,8 +2627,6 @@ PROXY_DECLARE(int) ap_proxy_connect_back
>  #if APR_HAVE_SYS_UN_H
>          if (conn->uds_path)
>          {
> -            struct sockaddr_un sa;
> -
>              rv = apr_socket_create(&newsock, AF_UNIX, SOCK_STREAM, 0,
>                                     conn->scpool);
>              if (rv != APR_SUCCESS) {
> @@ -2638,10 +2640,7 @@ PROXY_DECLARE(int) ap_proxy_connect_back
>              }
>              conn->connection = NULL;
>
> -            sa.sun_family = AF_UNIX;
> -            apr_cpystrn(sa.sun_path, conn->uds_path, sizeof(sa.sun_path));
> -
> -            rv = socket_connect_un(newsock, &sa);
> +            rv = ap_proxy_connect_uds(newsock, conn->uds_path,
> conn->scpool);
>              if (rv != APR_SUCCESS) {
>                  apr_socket_close(newsock);
>                  ap_log_error(APLOG_MARK, APLOG_ERR, rv, s, APLOGNO(02454)
>
>
>


-- 
Born in Roswell... married an alien...
http://emptyhammock.com/
http://edjective.org/