diff -ru apr-1.5.0/include/apr_network_io.h apr-1.5.0.new/include/apr_network_io.h --- apr-1.5.0/include/apr_network_io.h 2013-11-12 09:26:22.000000000 -0500 +++ apr-1.5.0.new/include/apr_network_io.h 2013-12-10 01:58:15.263988007 -0500 @@ -65,6 +65,7 @@ #define APR_SO_DEBUG 4 /**< Debug */ #define APR_SO_NONBLOCK 8 /**< Non-blocking IO */ #define APR_SO_REUSEADDR 16 /**< Reuse addresses */ +#define APR_SO_REUSEPORT 32 /**< Reuse port */ #define APR_SO_SNDBUF 64 /**< Send buffer */ #define APR_SO_RCVBUF 128 /**< Receive buffer */ #define APR_SO_DISCONNECTED 256 /**< Disconnected */ @@ -616,6 +617,8 @@ * APR_SO_REUSEADDR -- The rules used in validating addresses * supplied to bind should allow reuse * of local addresses. + * APR_SO_REUSEPORT -- This enable multiple sockets listen to + * the same ipaddress:port. * APR_SO_SNDBUF -- Set the SendBufferSize * APR_SO_RCVBUF -- Set the ReceiveBufferSize * @@ -650,6 +653,8 @@ * APR_SO_REUSEADDR -- The rules used in validating addresses * supplied to bind should allow reuse * of local addresses. + * APR_SO_REUSEPORT -- enable multiple sockets listen to + * the same ipaddress:port. * APR_SO_SNDBUF -- Set the SendBufferSize * APR_SO_RCVBUF -- Set the ReceiveBufferSize * APR_SO_DISCONNECTED -- Query the disconnected state of the socket. diff -ru apr-1.5.0/network_io/unix/sockopt.c apr-1.5.0.new/network_io/unix/sockopt.c --- apr-1.5.0/network_io/unix/sockopt.c 2012-11-07 11:10:09.000000000 -0500 +++ apr-1.5.0.new/network_io/unix/sockopt.c 2013-12-10 02:03:05.121983374 -0500 @@ -161,6 +161,20 @@ apr_set_option(sock, APR_SO_REUSEADDR, on); } break; +/* SO_REUSEPORT is enabled in the Linux kernel newer than 3.9. It allows + * multiple sockets listen to the same ipaddress:port. + */ + case APR_SO_REUSEPORT: +#ifndef SO_REUSEPORT +#define SO_REUSEPORT 15 + if(on != apr_is_option_set(sock, APR_SO_REUSEPORT)) { + if (setsockopt(sock->socketdes, SOL_SOCKET, SO_REUSEPORT, (void *)&one, sizeof(int)) == -1) { + return errno; + } + apr_set_option(sock, APR_SO_REUSEPORT, on); + } +#endif + break; case APR_SO_SNDBUF: #ifdef SO_SNDBUF if (setsockopt(sock->socketdes, SOL_SOCKET, SO_SNDBUF, (void *)&on, sizeof(int)) == -1) {