mirror of
https://gitlab.isc.org/isc-projects/bind9
synced 2025-08-29 13:38:26 +00:00
checkpoint new lwresd code
This commit is contained in:
parent
6cff00c8e1
commit
03eb24f79a
5
bin/lwresd/.cvsignore
Normal file
5
bin/lwresd/.cvsignore
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
Makefile
|
||||||
|
.libs
|
||||||
|
*.la
|
||||||
|
*.lo
|
||||||
|
lwresd
|
49
bin/lwresd/Makefile.in
Normal file
49
bin/lwresd/Makefile.in
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
# Copyright (C) 1998, 1999 Internet Software Consortium.
|
||||||
|
#
|
||||||
|
# Permission to use, copy, modify, and distribute this software for any
|
||||||
|
# purpose with or without fee is hereby granted, provided that the above
|
||||||
|
# copyright notice and this permission notice appear in all copies.
|
||||||
|
#
|
||||||
|
# THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS
|
||||||
|
# ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
|
||||||
|
# OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
|
||||||
|
# CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
|
||||||
|
# DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
|
||||||
|
# PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
|
||||||
|
# ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
|
||||||
|
# SOFTWARE.
|
||||||
|
|
||||||
|
srcdir = @srcdir@
|
||||||
|
VPATH = @srcdir@
|
||||||
|
top_srcdir = @top_srcdir@
|
||||||
|
|
||||||
|
@BIND9_VERSION@
|
||||||
|
|
||||||
|
@BIND9_INCLUDES@
|
||||||
|
|
||||||
|
CINCLUDES = \
|
||||||
|
${LWRES_INCLUDES} ${DNS_INCLUDES} ${ISC_INCLUDES}
|
||||||
|
|
||||||
|
CDEFINES =
|
||||||
|
CWARNINGS =
|
||||||
|
|
||||||
|
DEPLIBS = ../../lib/lwres/liblwres.@A@ \
|
||||||
|
../../lib/dns/libdns.@A@ \
|
||||||
|
../../lib/isc/libisc.@A@
|
||||||
|
|
||||||
|
LIBS = ${DEPLIBS} \
|
||||||
|
@LIBS@
|
||||||
|
|
||||||
|
TARGETS = lwresd
|
||||||
|
|
||||||
|
OBJS = main.@O@
|
||||||
|
|
||||||
|
SRCS = main.c
|
||||||
|
|
||||||
|
@BIND9_MAKE_RULES@
|
||||||
|
|
||||||
|
lwresd: ${OBJS} ${UOBJS} ${DEPLIBS}
|
||||||
|
${LIBTOOL} ${CC} -o $@ ${OBJS} ${UOBJS} ${LIBS}
|
||||||
|
|
||||||
|
clean distclean::
|
||||||
|
rm -f ${TARGETS}
|
43
bin/lwresd/client.h
Normal file
43
bin/lwresd/client.h
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 1999 Internet Software Consortium.
|
||||||
|
*
|
||||||
|
* Permission to use, copy, modify, and distribute this software for any
|
||||||
|
* purpose with or without fee is hereby granted, provided that the above
|
||||||
|
* copyright notice and this permission notice appear in all copies.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS
|
||||||
|
* ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
|
||||||
|
* OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
|
||||||
|
* CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
|
||||||
|
* DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
|
||||||
|
* PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
|
||||||
|
* ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
|
||||||
|
* SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef LWD_CLIENT_H
|
||||||
|
#define LWD_CLIENT_H 1
|
||||||
|
|
||||||
|
#include <isc/list.h>
|
||||||
|
#include <isc/mem.h>
|
||||||
|
#include <isc/sockaddr.h>
|
||||||
|
#include <isc/socket.h>
|
||||||
|
#include <isc/task.h>
|
||||||
|
|
||||||
|
typedef struct client_s client_t;
|
||||||
|
struct client_s {
|
||||||
|
isc_socket_t *socket; /* socket to reply */
|
||||||
|
isc_sockaddr_t sockaddr; /* where to reply */
|
||||||
|
unsigned char buffer[LWRES_RECVLENGTH]; /* receive buffer */
|
||||||
|
|
||||||
|
ISC_LINK(client_t) link;
|
||||||
|
};
|
||||||
|
|
||||||
|
typedef struct clientmgr_s clientmgr_t;
|
||||||
|
struct clientmgr_s {
|
||||||
|
isc_task_t *task; /* owning task */
|
||||||
|
ISC_LIST(client_t) idle; /* idle client slots */
|
||||||
|
ISC_LIST(client_t) running; /* running clients */
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif /* LWD_CLIENT_H */
|
108
bin/lwresd/main.c
Normal file
108
bin/lwresd/main.c
Normal file
@ -0,0 +1,108 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 1999 Internet Software Consortium.
|
||||||
|
*
|
||||||
|
* Permission to use, copy, modify, and distribute this software for any
|
||||||
|
* purpose with or without fee is hereby granted, provided that the above
|
||||||
|
* copyright notice and this permission notice appear in all copies.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS
|
||||||
|
* ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
|
||||||
|
* OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
|
||||||
|
* CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
|
||||||
|
* DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
|
||||||
|
* PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
|
||||||
|
* ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
|
||||||
|
* SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <config.h>
|
||||||
|
|
||||||
|
#include <lwres/lwres.h>
|
||||||
|
|
||||||
|
#include <isc/assertions.h>
|
||||||
|
#include <isc/mem.h>
|
||||||
|
#include <isc/result.h>
|
||||||
|
#include <isc/task.h>
|
||||||
|
#include <isc/util.h>
|
||||||
|
|
||||||
|
#include "client.h"
|
||||||
|
|
||||||
|
/*
|
||||||
|
* The goal number of clients we can handle will be NTASKS * NRECVS.
|
||||||
|
*/
|
||||||
|
#define NTASKS 10 /* tasks to create to handle lwres queries */
|
||||||
|
#define NRECVS 5 /* max clients per task */
|
||||||
|
#define NTHREADS 1 /* # threads to create in thread manager */
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Array of client managers. Each of these will have a task associated
|
||||||
|
* with it.
|
||||||
|
*/
|
||||||
|
clientmgr_t *cmgr;
|
||||||
|
unsigned int ntasks; /* number of tasks actually created */
|
||||||
|
|
||||||
|
int
|
||||||
|
main(int argc, char **argv)
|
||||||
|
{
|
||||||
|
isc_mem_t *mem;
|
||||||
|
isc_taskmgr_t *taskmgr;
|
||||||
|
isc_result_t result;
|
||||||
|
unsigned int i, j;
|
||||||
|
client_t *client;
|
||||||
|
|
||||||
|
UNUSED(argc);
|
||||||
|
UNUSED(argv);
|
||||||
|
|
||||||
|
mem = NULL;
|
||||||
|
result = isc_mem_create(0, 0, &mem);
|
||||||
|
INSIST(result == ISC_R_SUCCESS);
|
||||||
|
|
||||||
|
cmgr = isc_mem_get(mem, sizeof(clientmgr_t) * NTHREADS);
|
||||||
|
INSIST(cmgr != NULL);
|
||||||
|
|
||||||
|
taskmgr = NULL;
|
||||||
|
result = isc_taskmgr_create(mem, NTHREADS, 0, &taskmgr);
|
||||||
|
INSIST(result == ISC_R_SUCCESS);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Create one task for each client manager.
|
||||||
|
*/
|
||||||
|
for (i = 0 ; i < NTASKS ; i++) {
|
||||||
|
cmgr[i].task = NULL;
|
||||||
|
ISC_LIST_INIT(cmgr[i].idle);
|
||||||
|
ISC_LIST_INIT(cmgr[i].running);
|
||||||
|
result = isc_task_create(taskmgr, mem, 0, &cmgr[i].task);
|
||||||
|
INSIST(result == ISC_R_SUCCESS);
|
||||||
|
}
|
||||||
|
INSIST(i > 0);
|
||||||
|
ntasks = i; /* remember how many we managed to create */
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Now, run through each client manager and populate it with
|
||||||
|
* client structures. Do this by creating one receive for each
|
||||||
|
* task, in a loop, so each task has a chance of getting at least
|
||||||
|
* one client structure.
|
||||||
|
*/
|
||||||
|
for (i = 0 ; i < NRECVS ; i++) {
|
||||||
|
client = isc_mem_get(mem, sizeof(client_t) * ntasks);
|
||||||
|
if (client == NULL)
|
||||||
|
break;
|
||||||
|
for (j = 0 ; j < ntasks ; j++) {
|
||||||
|
client[j].socket = NULL;
|
||||||
|
ISC_LINK_INIT(&client[j], link);
|
||||||
|
ISC_LIST_APPEND(cmgr[j].idle, &client[j], link);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
INSIST(i > 0);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Now, create a socket. Issue one read request for each task
|
||||||
|
* we have.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Wait for ^c or kill.
|
||||||
|
*/
|
||||||
|
|
||||||
|
return (0);
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user