summaryrefslogtreecommitdiff
path: root/network_io
diff options
context:
space:
mode:
authorJeff Trawick <trawick@apache.org>2012-11-07 16:06:25 +0000
committerJeff Trawick <trawick@apache.org>2012-11-07 16:06:25 +0000
commita23c7aad83ec92baddbd7838488cb54bcb43eefe (patch)
treed58b3bef71501a589bf54841c61a8ce6bec9d0ec /network_io
parent78dc465fa0b20cccfa14adef5f79fdf8d63d9a00 (diff)
downloadapr-a23c7aad83ec92baddbd7838488cb54bcb43eefe.tar.gz
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) git-svn-id: https://svn.apache.org/repos/asf/apr/apr/trunk@1406690 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'network_io')
-rw-r--r--network_io/unix/sockopt.c21
1 files changed, 19 insertions, 2 deletions
diff --git a/network_io/unix/sockopt.c b/network_io/unix/sockopt.c
index 487d30957..8ba553230 100644
--- a/network_io/unix/sockopt.c
+++ b/network_io/unix/sockopt.c
@@ -397,8 +397,25 @@ apr_status_t apr_socket_accept_filter(apr_socket_t *sock, const char *name,
const char *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) {