Skip to content
Snippets Groups Projects
Commit 71758aff authored by Lubos Slovak's avatar Lubos Slovak
Browse files

Event queue moved to common library

parent 5a2b994a
Branches
Tags
No related merge requests found
......@@ -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
......
......@@ -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 \
......
......@@ -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;
}
......@@ -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_ */
/*! @} */
......@@ -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"
/*----------------------------------------------------------------------------*/
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment