2
0
mirror of https://gitlab.isc.org/isc-projects/bind9 synced 2025-08-31 14:35:26 +00:00

1203. [func] Use "dataready" accept filter if available.

This commit is contained in:
Mark Andrews
2002-05-27 00:40:23 +00:00
parent c9fc5bacab
commit a1edcd1b8d
6 changed files with 59 additions and 5 deletions

View File

@@ -15,7 +15,7 @@
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
/* $Id: socket.c,v 1.225 2002/04/03 06:44:11 marka Exp $ */
/* $Id: socket.c,v 1.226 2002/05/27 00:40:22 marka Exp $ */
#include <config.h>
@@ -2803,6 +2803,35 @@ isc_socket_bind(isc_socket_t *sock, isc_sockaddr_t *sockaddr) {
return (ISC_R_SUCCESS);
}
isc_result_t
isc_socket_filter(isc_socket_t *sock, const char *filter) {
#ifdef SO_ACCEPTFILTER
char strbuf[ISC_STRERRORSIZE];
struct accept_filter_arg afa;
#else
UNUSED(sock);
UNUSED(filter);
#endif
REQUIRE(VALID_SOCKET(sock));
#ifdef SO_ACCEPTFILTER
bzero(&afa, sizeof(afa));
strncpy(afa.af_name, filter, sizeof(afa.af_name));
if (setsockopt(sock->fd, SOL_SOCKET, SO_ACCEPTFILTER,
&afa, sizeof(afa)) == -1) {
isc__strerror(errno, strbuf, sizeof(strbuf));
socket_log(sock, NULL, CREATION, isc_msgcat, ISC_MSGSET_SOCKET,
ISC_MSG_FILTER, "setsockopt(SO_ACCEPTFILTER): %s",
strbuf);
return (ISC_R_FAILURE);
}
return (ISC_R_SUCCESS);
#else
return (ISC_R_NOTIMPLEMENTED);
#endif
}
/*
* Set up to listen on a given socket. We do this by creating an internal
* event that will be dispatched when the socket has read activity. The