diff --git a/Knot.files b/Knot.files index 0e0c900f14fc9d878999e2485e196cd1b9c8e570..da54c8ee3721f0170ef9c9864f337b58e0f8099d 100644 --- a/Knot.files +++ b/Knot.files @@ -21,6 +21,8 @@ src/common/skip-list.h src/common/tree.h src/common/base32hex.h src/common/base32hex.c +src/common/evqueue.c +src/common/evqueue.h src/dnslib/dnslib-common.h src/dnslib/dname.h src/dnslib/dname.c @@ -86,8 +88,6 @@ src/knot/other/log.c src/knot/other/log.h src/knot/other/error.c src/knot/other/error.h -src/knot/other/evqueue.c -src/knot/other/evqueue.h src/knot/stat/gatherer.c src/knot/stat/gatherer.h src/knot/stat/stat.h diff --git a/src/Makefile.am b/src/Makefile.am index 2d6c632429553243ddf7e566a14dceba8d5c0d04..13293fcc299e7c436efe7175e1425dcbaa0a3d6c 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -91,6 +91,8 @@ libknot_la_SOURCES = \ common/dynamic-array.h \ common/tree.h \ common/base32hex.h \ + common/evqueue.h \ + common/evqueue.c \ knot/stat/gatherer.c \ knot/stat/stat.c \ knot/stat/gatherer.h \ @@ -138,8 +140,6 @@ libknot_la_SOURCES = \ knot/other/log.c \ knot/other/log.h \ knot/other/debug.h \ - knot/other/evqueue.h \ - knot/other/evqueue.c \ knot/other/error.h \ knot/other/error.c \ knot/conf/cf-parse.y \ diff --git a/src/knot/other/evqueue.c b/src/common/evqueue.c similarity index 75% rename from src/knot/other/evqueue.c rename to src/common/evqueue.c index 23f590aaef34594768a8194bc1920c9b3e5caafa..5830a438a75333272aebee2a64b10a68910376cc 100644 --- a/src/knot/other/evqueue.c +++ b/src/common/evqueue.c @@ -2,9 +2,9 @@ #include <stdlib.h> #include <unistd.h> -#include "knot/common.h" -#include "knot/other/evqueue.h" -#include "knot/other/error.h" +//#include "knot/common.h" +#include "common/evqueue.h" +//#include "knot/other/error.h" /*! \brief Singleton application-wide event queue. */ evqueue_t *s_evqueue = 0; @@ -38,7 +38,7 @@ int evqueue_poll(evqueue_t *q, const sigset_t *sigmask) { /* Check. */ if (!q) { - return KNOT_EINVAL; + return /*KNOT_EINVAL*/ -1; } /* Prepare fd set. */ @@ -50,7 +50,8 @@ int evqueue_poll(evqueue_t *q, const sigset_t *sigmask) int ret = pselect(q->fds[EVQUEUE_READFD] + 1, &rfds, 0, 0, 0, sigmask); if (ret < 0) { - return knot_map_errno(EINTR, EINVAL, ENOMEM); +// return knot_map_errno(EINTR, EINVAL, ENOMEM); + return -1; } return ret; @@ -60,31 +61,33 @@ int evqueue_get(evqueue_t *q, event_t *ev) { /* Check. */ if (!q || !ev) { - return KNOT_EINVAL; + return /*KNOT_EINVAL*/ -1; } /* Read data. */ int ret = read(q->fds[EVQUEUE_READFD], ev, sizeof(event_t)); if (ret != sizeof(event_t)) { - return knot_map_errno(EINVAL, EINTR, EAGAIN); +// return knot_map_errno(EINVAL, EINTR, EAGAIN); + return -1; } - return KNOT_EOK; + return /*KNOT_EOK*/ 0; } int evqueue_add(evqueue_t *q, const event_t *ev) { /* Check. */ if (!q || !ev) { - return KNOT_EINVAL; + return /*KNOT_EINVAL*/ -1; } /* Write data. */ int ret = write(q->fds[EVQUEUE_WRITEFD], ev, sizeof(event_t)); if (ret != sizeof(event_t)) { - return knot_map_errno(EINVAL, EINTR, EAGAIN); +// return knot_map_errno(EINVAL, EINTR, EAGAIN); + return -1; } - return KNOT_EOK; + return /*KNOT_EOK*/ 0; } diff --git a/src/knot/other/evqueue.h b/src/common/evqueue.h similarity index 92% rename from src/knot/other/evqueue.h rename to src/common/evqueue.h index 9fa45ba5962fc02a499e6a3d50471515c6bec080..b15008c48a8b1541ff3d7a4cac51ed92a70d2d91 100644 --- a/src/knot/other/evqueue.h +++ b/src/common/evqueue.h @@ -5,15 +5,17 @@ * * \brief Event queue. * - * \addtogroup data_structures + * \addtogroup common_lib * @{ */ -#ifndef _CUTEDNS_EVQUEUE_H_ -#define _CUTEDNS_EVQUEUE_H_ + +#ifndef _KNOT_COMMON_EVQUEUE_H_ +#define _KNOT_COMMON_EVQUEUE_H_ #include <pthread.h> +#include <signal.h> // sigset_t -#include "knot/common.h" +//#include "knot/common.h" #include "common/lists.h" struct event_t; @@ -121,6 +123,6 @@ static inline void evqueue_set(evqueue_t *q) { s_evqueue = q; } -#endif /* _CUTEDNS_EVQUEUE_H_ */ +#endif /* _KNOT_COMMON_EVQUEUE_H_ */ /*! @} */ diff --git a/src/knot/main.c b/src/knot/main.c index bdb8d9c891d8b1fd96e7324657b793f44e2ae3f0..ffb8c22b8655ac34f471552ff6e2fff30e32937d 100644 --- a/src/knot/main.c +++ b/src/knot/main.c @@ -9,7 +9,7 @@ #include "knot/ctl/process.h" #include "knot/conf/conf.h" #include "knot/conf/logconf.h" -#include "knot/other/evqueue.h" +#include "common/evqueue.h" /*----------------------------------------------------------------------------*/