Deleted Added
full compact
sockopt.c (251886) sockopt.c (253734)
1/* Licensed to the Apache Software Foundation (ASF) under one or more
2 * contributor license agreements. See the NOTICE file distributed with
3 * this work for additional information regarding copyright ownership.
4 * The ASF licenses this file to You under the Apache License, Version 2.0
5 * (the "License"); you may not use this file except in compliance with
6 * the License. You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0

--- 367 unchanged lines hidden (view full) ---

376 */
377 buf[0] = '\0';
378 return APR_ENAMETOOLONG;
379 }
380 return APR_SUCCESS;
381}
382
383#if APR_HAS_SO_ACCEPTFILTER
1/* Licensed to the Apache Software Foundation (ASF) under one or more
2 * contributor license agreements. See the NOTICE file distributed with
3 * this work for additional information regarding copyright ownership.
4 * The ASF licenses this file to You under the Apache License, Version 2.0
5 * (the "License"); you may not use this file except in compliance with
6 * the License. You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0

--- 367 unchanged lines hidden (view full) ---

376 */
377 buf[0] = '\0';
378 return APR_ENAMETOOLONG;
379 }
380 return APR_SUCCESS;
381}
382
383#if APR_HAS_SO_ACCEPTFILTER
384apr_status_t apr_socket_accept_filter(apr_socket_t *sock, char *name,
385 char *args)
384apr_status_t apr_socket_accept_filter(apr_socket_t *sock, char *nonconst_name,
385 char *nonconst_args)
386{
386{
387 /* these should have been const; act like they are */
388 const char *name = nonconst_name;
389 const char *args = nonconst_args;
390
387 struct accept_filter_arg af;
391 struct accept_filter_arg af;
388 strncpy(af.af_name, name, 16);
389 strncpy(af.af_arg, args, 256 - 16);
392 socklen_t optlen = sizeof(af);
390
393
394 /* FreeBSD returns an error if the filter is already set; ignore
395 * this call if we previously set it to the same value.
396 */
397 if ((getsockopt(sock->socketdes, SOL_SOCKET, SO_ACCEPTFILTER,
398 &af, &optlen)) == 0) {
399 if (!strcmp(name, af.af_name) && !strcmp(args, af.af_arg)) {
400 return APR_SUCCESS;
401 }
402 }
403
404 /* Uhh, at least in FreeBSD 9 the fields are declared as arrays of
405 * these lengths; did sizeof not work in some ancient release?
406 *
407 * FreeBSD kernel sets the last byte to a '\0'.
408 */
409 apr_cpystrn(af.af_name, name, 16);
410 apr_cpystrn(af.af_arg, args, 256 - 16);
411
391 if ((setsockopt(sock->socketdes, SOL_SOCKET, SO_ACCEPTFILTER,
392 &af, sizeof(af))) < 0) {
393 return errno;
394 }
395 return APR_SUCCESS;
396}
397#endif
412 if ((setsockopt(sock->socketdes, SOL_SOCKET, SO_ACCEPTFILTER,
413 &af, sizeof(af))) < 0) {
414 return errno;
415 }
416 return APR_SUCCESS;
417}
418#endif