X-Git-Url: http://git.madism.org/?a=blobdiff_plain;f=common%2Frbl.c;h=416f2221cf30dbddef1690ed1f51a9c513bccafa;hb=39e8c944acc71c4e3deaa48d55c09279fd80d81f;hp=d83d9dfd248ee09ce8118465de22c685133881e7;hpb=6119309deb6946c7d19e29c883008aa88c410e66;p=apps%2Fpfixtools.git diff --git a/common/rbl.c b/common/rbl.c index d83d9df..416f222 100644 --- a/common/rbl.c +++ b/common/rbl.c @@ -36,7 +36,6 @@ #include #include #include "array.h" -#include "epoll.h" #include "server.h" #include "rbl.h" @@ -49,6 +48,7 @@ typedef struct rbl_context_t { 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) @@ -89,6 +89,10 @@ static void rbl_exit(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); @@ -107,24 +111,21 @@ static void rbl_callback(void *arg, int err, struct ub_result *result) *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; } @@ -134,7 +135,7 @@ static inline bool rbl_dns_check(const char *hostname, rbl_result_t *result, 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(); }