/* products derived from this software without specific prior written */
/* permission. */
/* */
-/* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND */
-/* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE */
-/* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR */
-/* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS */
-/* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR */
-/* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF */
-/* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS */
-/* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN */
-/* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) */
-/* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF */
-/* THE POSSIBILITY OF SUCH DAMAGE. */
+/* THIS SOFTWARE IS PROVIDED BY THE CONTRIBUTORS ``AS IS'' AND ANY EXPRESS */
+/* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED */
+/* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE */
+/* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY */
+/* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL */
+/* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS */
+/* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) */
+/* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, */
+/* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN */
+/* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE */
+/* POSSIBILITY OF SUCH DAMAGE. */
+/* */
+/* Copyright (c) 2006-2008 the Authors */
+/* see AUTHORS and source files for details */
/******************************************************************************/
/*
#include <unbound.h>
#include <netdb.h>
#include "array.h"
-#include "epoll.h"
#include "server.h"
#include "rbl.h"
ARRAY(rbl_context_t);
static struct ub_ctx *ctx = NULL;
+static client_t *async_event = NULL;
static PA(rbl_context_t) ctx_pool = ARRAY_INIT;
static rbl_context_t *rbl_context_new(void)
ub_ctx_delete(ctx);
ctx = NULL;
}
+ if (async_event != NULL) {
+ client_release(async_event);
+ async_event = NULL;
+ }
array_deep_wipe(ctx_pool, rbl_context_delete);
}
module_exit(rbl_exit);
*context->result = RBL_FOUND;
}
if (context->call != NULL) {
- debug("calling callback");
context->call(context->result, context->data);
- } else {
- debug("no callback defined");
}
ub_resolve_free(result);
rbl_context_release(context);
}
-static int rbl_handler(server_t *event, void *config)
+static int rbl_handler(client_t *event, void *config)
{
int retval = 0;
debug("rbl_handler called: ub_fd triggered");
- epoll_modify(event->fd, 0, event);
+ client_io_none(event);
if ((retval = ub_process(ctx)) != 0) {
err("error in DNS resolution: %s", ub_strerror(retval));
}
- epoll_modify(event->fd, EPOLLIN, event);
+ client_io_ro(event);
return 0;
}
if (ctx == NULL) {
ctx = ub_ctx_create();
ub_ctx_async(ctx, true);
- if (server_register(ub_fd(ctx), rbl_handler, NULL) == NULL) {
+ if ((async_event = client_register(ub_fd(ctx), rbl_handler, NULL)) == NULL) {
crit("cannot register asynchronous DNS event handler");
abort();
}
context->result = result;
context->call = callback;
context->data = data;
+ debug("running dns resolution on %s", hostname);
if (ub_resolve_async(ctx, (char*)hostname, 1, 1, context, rbl_callback, NULL) == 0) {
*result = RBL_ASYNC;
return true;