aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGilles Chehade <gilles@poolp.org>2020-01-09 15:41:22 +0100
committerGilles Chehade <gilles@poolp.org>2020-01-09 15:41:22 +0100
commitcf4641d29520071cc26576b6d6c390dafc42296d (patch)
tree32c09e1415f8a054e5f48ebded33fed8bd72df7e
parentfix asr warnings (diff)
downloadOpenSMTPD-cf4641d29520071cc26576b6d6c390dafc42296d.tar.xz
OpenSMTPD-cf4641d29520071cc26576b6d6c390dafc42296d.zip
event_asr_run.c is better in openbsd-compat than in libasr actually
-rw-r--r--openbsd-compat/Makefile.am7
-rw-r--r--openbsd-compat/libasr/event_asr_run.c88
2 files changed, 3 insertions, 92 deletions
diff --git a/openbsd-compat/Makefile.am b/openbsd-compat/Makefile.am
index 4ec0e642..d08fbed8 100644
--- a/openbsd-compat/Makefile.am
+++ b/openbsd-compat/Makefile.am
@@ -11,7 +11,6 @@ libopenbsd_a_SOURCES += libasr/asr.c
libopenbsd_a_SOURCES += libasr/asr_debug.c
libopenbsd_a_SOURCES += libasr/asr_compat.c
libopenbsd_a_SOURCES += libasr/asr_utils.c
-libopenbsd_a_SOURCES += libasr/event_asr_run.c
libopenbsd_a_SOURCES += libasr/getaddrinfo_async.c
libopenbsd_a_SOURCES += libasr/gethostnamadr_async.c
libopenbsd_a_SOURCES += libasr/getnameinfo_async.c
@@ -68,9 +67,9 @@ if NEED_ERRC
libopenbsd_a_SOURCES += errc.c
endif
-#if NEED_EVENT_ASR_RUN
-#libopenbsd_a_SOURCES += event_asr_run.c
-#endif
+if NEED_EVENT_ASR_RUN
+libopenbsd_a_SOURCES += event_asr_run.c
+endif
if NEED_EXPLICIT_BZERO
libopenbsd_a_SOURCES += explicit_bzero.c
diff --git a/openbsd-compat/libasr/event_asr_run.c b/openbsd-compat/libasr/event_asr_run.c
deleted file mode 100644
index aef86154..00000000
--- a/openbsd-compat/libasr/event_asr_run.c
+++ /dev/null
@@ -1,88 +0,0 @@
-/* $OpenBSD$ */
-/*
- * Copyright (c) 2012 Eric Faurot <eric@openbsd.org>
- *
- * Permission to use, copy, modify, and distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
- * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
- * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- */
-
-#include "includes.h"
-
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <netdb.h>
-
-#include <asr.h>
-#include <event.h>
-#include <stdlib.h>
-
-struct event_asr {
- struct event ev;
- struct asr_query *async;
- void (*cb)(struct asr_result *, void *);
- void *arg;
-};
-
-struct event_asr * event_asr_run(struct asr_query *,
- void (*)(struct asr_result *, void *), void *);
-void event_asr_abort(struct event_asr *);
-
-static void
-event_asr_dispatch(int fd __attribute__((__unused__)),
- short ev __attribute__((__unused__)), void *arg)
-{
- struct event_asr *eva = arg;
- struct asr_result ar;
- struct timeval tv;
-
- event_del(&eva->ev);
-
- if (asr_run(eva->async, &ar)) {
- eva->cb(&ar, eva->arg);
- free(eva);
- } else {
- event_set(&eva->ev, ar.ar_fd,
- ar.ar_cond == ASR_WANT_READ ? EV_READ : EV_WRITE,
- event_asr_dispatch, eva);
- tv.tv_sec = ar.ar_timeout / 1000;
- tv.tv_usec = (ar.ar_timeout % 1000) * 1000;
- event_add(&eva->ev, &tv);
- }
-}
-
-struct event_asr *
-event_asr_run(struct asr_query *async, void (*cb)(struct asr_result *, void *),
- void *arg)
-{
- struct event_asr *eva;
- struct timeval tv;
-
- eva = calloc(1, sizeof *eva);
- if (eva == NULL)
- return (NULL);
- eva->async = async;
- eva->cb = cb;
- eva->arg = arg;
- tv.tv_sec = 0;
- tv.tv_usec = 0;
- evtimer_set(&eva->ev, event_asr_dispatch, eva);
- evtimer_add(&eva->ev, &tv);
- return (eva);
-}
-
-void
-event_asr_abort(struct event_asr *eva)
-{
- asr_abort(eva->async);
- event_del(&eva->ev);
- free(eva);
-}