DragonFly BSD
DragonFly kernel List (threaded) for 2003-11
[Date Prev][Date Next]  [Thread Prev][Thread Next]  [Date Index][Thread Index]

Re: Bind update


From: David Rhodus <drhodus@xxxxxxxxx>
Date: Sat, 22 Nov 2003 21:37:50 -0500

Richard Coleman wrote:

Do you envision all this being handled by daemons running as pure kernel threads? It would be cool if DragonFly could have a standard API for asynchronous DNS resolutions.

I really like the idea of something like a lookupd, like darwin has, not only for resolver type
of things but also authentication.


As for async lookups API, most likely we will follow the same path everyone else has as
it mainly for application developers use(in my mind). Here kind of an API guide I think
we should follow in DragonFly for asynchronous lookup's.


There are quite a few interface available today for
host lookup (gethostbyname,gethostname2,getaddrinfo...)
AIO(asynchronous I/O) API introduced in POSIX-1b

<netdb.h> -- definitions for newwork database opertations

const char *ar_name;	/* Host name to look up */
const char *ar_service;	/* Service name. */
const struct addrinfo *ar_request; /* Request attributes. */
struct addrinfo *ar_result;	/* Pointer to first
				element of result. */

getaddrinfo_a()
GAI_WAIT
	The function will not return intil all the work is done.
GAI_NOWAIT
	The function immediately return after queueing the requests.

int getaddrinfo_a(int, struct gaicb *restrict [restrict], int
			struct sigevent *restrict);
int gai_suspend(const struct gaicb *restrict
		const[restrict], int,
		const strcut timespec *restrict);
int gai_error(struct gaicb *);
int gai_cabcel(struct gaicb *);


getaddrinfo_a() asynchronicall get address information gai_suspend Suspend execution until a request result is available gai_error() Get status of lookup request gai_cancel Cancel an asynchronous name lookup request



Example

int new_name;

/* This is the sginal handler. We just set a flag that
when poll() returns(which happens right after the signal
handler return) the flag is set and we can use the name.
*/
void sighandle (int sig) { new_name = 1;
}


	/* This is the array with the request. This will probably
	have to be dynamic in size in a real implementiation
	*/
	{
	struct gaicb reqs[10];
	struct sigeven sigev = {
		.sigev_notify = SIGEV_SIGNAL,
		.sigev_signo = SIGRT1
	};
	struct sigaction sa = {
		.sa_handle = sighandler,
		sa._flahgs = 0 /* Note: not SA_RESTART */
	};
	sigemptyset (&sa.sa_mask);

	/* Install signal handler. */
	/* All requests are reported using the same machanism:
	with a signal send. We initialize a sigevent struct,
	a sigaction structre, and set using sigaction() the
	signal handler for later use.
	*/

	while(1) {
	/* Wait until data is available or interrupted
	   by a signal. */
	int n = poll(fds, nfds, 0);
	/* This poll() call serves two purposes. First, we track
	multiple incoming connections. this could be the different
	files makeing up a request.

	But unless the SA_RESTART flag is set for the signal hanlder
	poll() return with an EINTR error if a signal is delivered.
	This is what we use here. After SIGRT1 is delivered (sighandler()
	is called)poll() return with a value zero.
	*/

/* See whether any name got resolved. We can come
here even if no stream has input (i.e., n == 0)
since we are using signal from notification for
sinished lookups. This causes poll() to return
with errno == EINTR. */
if (new_name != 0) {
int i;
/* here we seatch for a finished request and initiate
a connection baed on the information ... */
/* This is where we recognize newly resolved names and
start using them. */
}


	if ( n != 0) {
		/* read from descriptors */

if (URL) {
/*
If the test read for the URL contains a reference to another entiy we initiate here a new lookpup request
*/
int idx = find_free_req_idx();
reqs[idx].ar_name = URL;
reqs[idx].ar_service = htons(80); /* HTTP port */
reqs[idx].ar_request = NULL;


			getaddrinfo_a(GAI_NOWAIT, &reqs[idx], 1, &sigeev);
			}
		}
	}



And given all the discussion in FreeBSD-current in the last few days about the changes to make /bin and /sbin dynamic so that NSS works correctly, I would be interested how this could be better achieved in the DragonFly world?

DragonFly will not have a dynamic / unless someone does a custom compile for their system.
As for NSS I'm not sure that is the best thing at this point....


-DR




[Date Prev][Date Next]  [Thread Prev][Thread Next]  [Date Index][Thread Index]