You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@apr.apache.org by tr...@apache.org on 2012/11/07 17:10:09 UTC
svn commit: r1406693 - in /apr/apr/branches/1.5.x: ./
network_io/unix/sockopt.c
Author: trawick
Date: Wed Nov 7 16:10:09 2012
New Revision: 1406693
URL: http://svn.apache.org/viewvc?rev=1406693&view=rev
Log:
merge r1406690 from trunk:
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.5.x/ (props changed)
apr/apr/branches/1.5.x/network_io/unix/sockopt.c
Propchange: apr/apr/branches/1.5.x/
------------------------------------------------------------------------------
Merged /apr/apr/trunk:r1406690
Modified: apr/apr/branches/1.5.x/network_io/unix/sockopt.c
URL: http://svn.apache.org/viewvc/apr/apr/branches/1.5.x/network_io/unix/sockopt.c?rev=1406693&r1=1406692&r2=1406693&view=diff
==============================================================================
--- apr/apr/branches/1.5.x/network_io/unix/sockopt.c (original)
+++ apr/apr/branches/1.5.x/network_io/unix/sockopt.c Wed Nov 7 16:10:09 2012
@@ -401,8 +401,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) {