X-Git-Url: http://git.madism.org/?a=blobdiff_plain;f=common%2Frbl.c;h=e7c79fb66e34706999319a067d223b1fb107e9c4;hb=b0194db8ea91d49b9e50319f6e20b8f580e338ed;hp=f0b5d556c48d491fa76e65d8c20ab5128c8bd295;hpb=6deab7a7086ccb592daa0c41e12759ec0b9c7aa0;p=apps%2Fpfixtools.git diff --git a/common/rbl.c b/common/rbl.c index f0b5d55..e7c79fb 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 server_t *async_event = NULL; static PA(rbl_context_t) ctx_pool = ARRAY_INIT; static rbl_context_t *rbl_context_new(void) @@ -89,6 +89,11 @@ static void rbl_exit(void) ub_ctx_delete(ctx); ctx = NULL; } + if (async_event != NULL) { + async_event->fd = -1; + server_release(async_event); + async_event = NULL; + } array_deep_wipe(ctx_pool, rbl_context_delete); } module_exit(rbl_exit); @@ -120,11 +125,11 @@ static int rbl_handler(server_t *event, void *config) { int retval = 0; debug("rbl_handler called: ub_fd triggered"); - epoll_modify(event->fd, 0, event); + server_none(event); if ((retval = ub_process(ctx)) != 0) { err("error in DNS resolution: %s", ub_strerror(retval)); } - epoll_modify(event->fd, EPOLLIN, event); + server_ro(event); return 0; } @@ -134,7 +139,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 = server_register(ub_fd(ctx), rbl_handler, NULL)) == NULL) { crit("cannot register asynchronous DNS event handler"); abort(); } @@ -143,6 +148,7 @@ static inline bool rbl_dns_check(const char *hostname, rbl_result_t *result, 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;