Beispiel #1
0
/* assumption: input limited; accept blocking on output */
static int master(void)
{
	for (;; ) {
		lsw_fd_set readfds;
		int maxfd = PLUTO_QFD;  /* approximate lower bound */
		int ndes = 0;
		struct worker_info *w;

		LSW_FD_ZERO(&readfds);
		if (!eof_from_pluto) {
			LSW_FD_SET(PLUTO_QFD, &readfds);
			ndes++;
		}
		for (w = wi; w != wi_roof; w++) {
			if (w->busy) {
				LSW_FD_SET(w->afd, &readfds);
				ndes++;
				if (maxfd < w->afd)
					maxfd = w->afd;
			}
		}

		if (ndes == 0)
			return HES_OK; /* done! */

		do
			ndes =
				lsw_select(maxfd + 1, &readfds, NULL, NULL,
					   NULL);
		while (ndes == -1 && errno == EINTR);
		if (ndes == -1) {
			syslog(LOG_ERR, "select(2) error: %s",
			       strerror(errno));
			exit(HES_IO_ERROR_SELECT);
		} else if (ndes > 0) {
			if (LSW_FD_ISSET(PLUTO_QFD, &readfds)) {
				query();
				ndes--;
			}
			for (w = wi; ndes > 0 && w != wi_roof; w++) {
				if (w->busy &&
				    LSW_FD_ISSET(w->afd, &readfds)) {
					answer(w);
					ndes--;
				}
			}
		}
	}
}
Beispiel #2
0
void enumerate_crypto_helper_response_sockets(lsw_fd_set *readfds)
{
	int cnt;
	struct pluto_crypto_worker *w = pc_workers;

	for (cnt = 0; cnt < pc_workers_cnt; cnt++, w++) {
		if (!w->pcw_dead) {
			passert(w->pcw_master_fd > 0);

			LSW_FD_SET(w->pcw_master_fd, readfds);
		}
	}
}