Return-Path: X-Original-To: apmail-apr-commits-archive@www.apache.org Delivered-To: apmail-apr-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 72053D69E for ; Wed, 7 Nov 2012 16:21:24 +0000 (UTC) Received: (qmail 45636 invoked by uid 500); 7 Nov 2012 16:13:51 -0000 Delivered-To: apmail-apr-commits-archive@apr.apache.org Received: (qmail 45492 invoked by uid 500); 7 Nov 2012 16:13:47 -0000 Mailing-List: contact commits-help@apr.apache.org; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: Reply-To: dev@apr.apache.org List-Id: Delivered-To: mailing list commits@apr.apache.org Received: (qmail 45428 invoked by uid 99); 7 Nov 2012 16:13:45 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 07 Nov 2012 16:13:45 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED,T_FRT_STOCK2 X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 07 Nov 2012 16:13:42 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id C92AB23888CD for ; Wed, 7 Nov 2012 16:13:21 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1406694 - in /apr/apr/branches/1.4.x: ./ CHANGES network_io/unix/sockopt.c Date: Wed, 07 Nov 2012 16:13:21 -0000 To: commits@apr.apache.org From: trawick@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20121107161321.C92AB23888CD@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: trawick Date: Wed Nov 7 16:13:21 2012 New Revision: 1406694 URL: http://svn.apache.org/viewvc?rev=1406694&view=rev Log: Trunk r1406690: apr_socket_accept_filter: Return success when trying to again set the filter to the same value as before. Use apr_cpystrn(). PR: 37863 (warning message from Apache httpd during restart) Modified: apr/apr/branches/1.4.x/ (props changed) apr/apr/branches/1.4.x/CHANGES apr/apr/branches/1.4.x/network_io/unix/sockopt.c Propchange: apr/apr/branches/1.4.x/ ------------------------------------------------------------------------------ Merged /apr/apr/trunk:r1406690 Modified: apr/apr/branches/1.4.x/CHANGES URL: http://svn.apache.org/viewvc/apr/apr/branches/1.4.x/CHANGES?rev=1406694&r1=1406693&r2=1406694&view=diff ============================================================================== --- apr/apr/branches/1.4.x/CHANGES [utf-8] (original) +++ apr/apr/branches/1.4.x/CHANGES [utf-8] Wed Nov 7 16:13:21 2012 @@ -1,6 +1,10 @@ -*- coding: utf-8 -*- Changes for APR 1.4.7 + *) apr_socket_accept_filter: Return success when trying to again set + the filter to the same value as before, avoiding an unhelpful + APR_EINVAL. PR 37863. [Jeff Trawick] + *) configure: Fix Linux 3.x detection. PR 54001. [Gilles Espinasse ] Modified: apr/apr/branches/1.4.x/network_io/unix/sockopt.c URL: http://svn.apache.org/viewvc/apr/apr/branches/1.4.x/network_io/unix/sockopt.c?rev=1406694&r1=1406693&r2=1406694&view=diff ============================================================================== --- apr/apr/branches/1.4.x/network_io/unix/sockopt.c (original) +++ apr/apr/branches/1.4.x/network_io/unix/sockopt.c Wed Nov 7 16:13:21 2012 @@ -389,8 +389,25 @@ apr_status_t apr_socket_accept_filter(ap const char *args = nonconst_args; struct accept_filter_arg af; - strncpy(af.af_name, name, 16); - strncpy(af.af_arg, args, 256 - 16); + socklen_t optlen = sizeof(af); + + /* FreeBSD returns an error if the filter is already set; ignore + * this call if we previously set it to the same value. + */ + if ((getsockopt(sock->socketdes, SOL_SOCKET, SO_ACCEPTFILTER, + &af, &optlen)) == 0) { + if (!strcmp(name, af.af_name) && !strcmp(args, af.af_arg)) { + return APR_SUCCESS; + } + } + + /* Uhh, at least in FreeBSD 9 the fields are declared as arrays of + * these lengths; did sizeof not work in some ancient release? + * + * FreeBSD kernel sets the last byte to a '\0'. + */ + apr_cpystrn(af.af_name, name, 16); + apr_cpystrn(af.af_arg, args, 256 - 16); if ((setsockopt(sock->socketdes, SOL_SOCKET, SO_ACCEPTFILTER, &af, sizeof(af))) < 0) {