<p>laforge has uploaded this change for <strong>review</strong>.</p><p><a href="https://gerrit.osmocom.org/c/libosmocore/+/21930">View Change</a></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">Add inter-thread queue<br><br>This adds an inter-thread queue "it_q" to libosmocore. With it_q,<br>one can perform thread-safe enqueing of messages to another thread,<br>who will receive the related messages triggered via an eventfd<br>handled in the usual libosmocore select loop abstraction.<br><br>Change-Id: Ie7d0c5fec715a2a577fae014b0b8a0e9c38418ef<br>---<br>M configure.ac<br>M include/Makefile.am<br>A include/osmocom/core/it_q.h<br>M src/Makefile.am<br>A src/it_q.c<br>M tests/Makefile.am<br>A tests/it_q/it_q_test.c<br>A tests/it_q/it_q_test.ok<br>M tests/testsuite.at<br>9 files changed, 485 insertions(+), 1 deletion(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/30/21930/1</pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/configure.ac b/configure.ac</span><br><span>index 10fb496..c062e5f 100644</span><br><span>--- a/configure.ac</span><br><span>+++ b/configure.ac</span><br><span>@@ -62,7 +62,7 @@</span><br><span> </span><br><span> dnl checks for header files</span><br><span> AC_HEADER_STDC</span><br><span style="color: hsl(0, 100%, 40%);">-AC_CHECK_HEADERS(execinfo.h poll.h sys/select.h sys/socket.h sys/signalfd.h sys/timerfd.h syslog.h ctype.h netinet/tcp.h netinet/in.h)</span><br><span style="color: hsl(120, 100%, 40%);">+AC_CHECK_HEADERS(execinfo.h poll.h sys/select.h sys/socket.h sys/signalfd.h sys/eventfd.h sys/timerfd.h syslog.h ctype.h netinet/tcp.h netinet/in.h)</span><br><span> # for src/conv.c</span><br><span> AC_FUNC_ALLOCA</span><br><span> AC_SEARCH_LIBS([dlopen], [dl dld], [LIBRARY_DLOPEN="$LIBS";LIBS=""])</span><br><span>diff --git a/include/Makefile.am b/include/Makefile.am</span><br><span>index 842b872..c1ae644 100644</span><br><span>--- a/include/Makefile.am</span><br><span>+++ b/include/Makefile.am</span><br><span>@@ -30,6 +30,7 @@</span><br><span>                        osmocom/core/hash.h \</span><br><span>                        osmocom/core/hashtable.h \</span><br><span>                        osmocom/core/isdnhdlc.h \</span><br><span style="color: hsl(120, 100%, 40%);">+                       osmocom/core/it_q.h \</span><br><span>                        osmocom/core/linuxlist.h \</span><br><span>                        osmocom/core/linuxrbtree.h \</span><br><span>                        osmocom/core/log2.h \</span><br><span>diff --git a/include/osmocom/core/it_q.h b/include/osmocom/core/it_q.h</span><br><span>new file mode 100644</span><br><span>index 0000000..6297840</span><br><span>--- /dev/null</span><br><span>+++ b/include/osmocom/core/it_q.h</span><br><span>@@ -0,0 +1,65 @@</span><br><span style="color: hsl(120, 100%, 40%);">+#pragma once</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+#include <osmocom/core/linuxlist.h></span><br><span style="color: hsl(120, 100%, 40%);">+#include <osmocom/core/select.h></span><br><span style="color: hsl(120, 100%, 40%);">+#include <pthread.h></span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+/*! \defgroup osmo_it_q Inter-Thread Queue</span><br><span style="color: hsl(120, 100%, 40%);">+ *  @{</span><br><span style="color: hsl(120, 100%, 40%);">+ *  \file osmo_it_q.h */</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+/*! One instance of an inter-thread queue.  The user can use this to queue messages</span><br><span style="color: hsl(120, 100%, 40%);">+ *  between different threads.  The enqueue operation is non-blocking (but of course</span><br><span style="color: hsl(120, 100%, 40%);">+ *  grabs a mutex for the actual list operations to safeguard againt races).  The</span><br><span style="color: hsl(120, 100%, 40%);">+ *  receiving thread is woken up by an event_fd which can be registered in the libosmocore</span><br><span style="color: hsl(120, 100%, 40%);">+ *  select loop handling.</span><br><span style="color: hsl(120, 100%, 40%);">+ *</span><br><span style="color: hsl(120, 100%, 40%);">+ *  IMPORTANT: Callers *MUST* ensure that items enqueued using osmo_it_q contain a</span><br><span style="color: hsl(120, 100%, 40%);">+ *  'struct llist_head' at the very beginning. */</span><br><span style="color: hsl(120, 100%, 40%);">+struct osmo_it_q {</span><br><span style="color: hsl(120, 100%, 40%);">+        /* entry in global list of message queues */</span><br><span style="color: hsl(120, 100%, 40%);">+  struct llist_head entry;</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+    /* the actual list of user structs. HEAD: first in queue; TAIL: last in queue */</span><br><span style="color: hsl(120, 100%, 40%);">+      struct llist_head list;</span><br><span style="color: hsl(120, 100%, 40%);">+       /* A pthread mutex to safeguard accesses to the queue. No rwlock as we always write. */</span><br><span style="color: hsl(120, 100%, 40%);">+       pthread_mutex_t mutex;</span><br><span style="color: hsl(120, 100%, 40%);">+        /* Current count of messages in the queue */</span><br><span style="color: hsl(120, 100%, 40%);">+  unsigned int current_length;</span><br><span style="color: hsl(120, 100%, 40%);">+  /* osmo-fd wrapped eventfd */</span><br><span style="color: hsl(120, 100%, 40%);">+ struct osmo_fd event_ofd;</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+   /* a user-defined name for this queue */</span><br><span style="color: hsl(120, 100%, 40%);">+      const char *name;</span><br><span style="color: hsl(120, 100%, 40%);">+     /* maximum permitted length of queue */</span><br><span style="color: hsl(120, 100%, 40%);">+       unsigned int max_length;</span><br><span style="color: hsl(120, 100%, 40%);">+      /* read call-back, called for each de-queued message */</span><br><span style="color: hsl(120, 100%, 40%);">+       void (*read_cb)(struct osmo_it_q *q, void *item);</span><br><span style="color: hsl(120, 100%, 40%);">+     /* opaque data pointer passed through to call-back function */</span><br><span style="color: hsl(120, 100%, 40%);">+        void *data;</span><br><span style="color: hsl(120, 100%, 40%);">+};</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+struct osmo_it_q *osmo_it_q_by_name(const char *name);</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+int _osmo_it_q_enqueue(struct osmo_it_q *queue, struct llist_head *item);</span><br><span style="color: hsl(120, 100%, 40%);">+#define osmo_it_q_enqueue(queue, item, member) \</span><br><span style="color: hsl(120, 100%, 40%);">+      _osmo_it_q_enqueue(queue, &(item)->member)</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+struct llist_head *_osmo_it_q_dequeue(struct osmo_it_q *queue);</span><br><span style="color: hsl(120, 100%, 40%);">+#define osmo_it_q_dequeue(queue, item, member) do {                       \</span><br><span style="color: hsl(120, 100%, 40%);">+     struct llist_head *l = _osmo_it_q_dequeue(queue);               \</span><br><span style="color: hsl(120, 100%, 40%);">+     if (!l)                                                         \</span><br><span style="color: hsl(120, 100%, 40%);">+             *item = NULL;                                           \</span><br><span style="color: hsl(120, 100%, 40%);">+     else                                                            \</span><br><span style="color: hsl(120, 100%, 40%);">+             *item = llist_entry(l, typeof(**item), member);         \</span><br><span style="color: hsl(120, 100%, 40%);">+} while (0)</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+struct osmo_it_q *osmo_it_q_alloc(void *ctx, const char *name, unsigned int max_length,</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+                                 void (*read_cb)(struct osmo_it_q *q, void *item),</span><br><span style="color: hsl(120, 100%, 40%);">+                                     void *data);</span><br><span style="color: hsl(120, 100%, 40%);">+void osmo_it_q_destroy(struct osmo_it_q *q);</span><br><span style="color: hsl(120, 100%, 40%);">+void osmo_it_q_flush(struct osmo_it_q *q);</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+/*! @} */</span><br><span>diff --git a/src/Makefile.am b/src/Makefile.am</span><br><span>index 5ff1a42..dd31db8 100644</span><br><span>--- a/src/Makefile.am</span><br><span>+++ b/src/Makefile.am</span><br><span>@@ -28,6 +28,7 @@</span><br><span>                      sockaddr_str.c \</span><br><span>                     use_count.c \</span><br><span>                        exec.c \</span><br><span style="color: hsl(120, 100%, 40%);">+                      it_q.c \</span><br><span>                     $(NULL)</span><br><span> </span><br><span> if HAVE_SSSE3</span><br><span>diff --git a/src/it_q.c b/src/it_q.c</span><br><span>new file mode 100644</span><br><span>index 0000000..9095d85</span><br><span>--- /dev/null</span><br><span>+++ b/src/it_q.c</span><br><span>@@ -0,0 +1,275 @@</span><br><span style="color: hsl(120, 100%, 40%);">+/*! \file it_q.c</span><br><span style="color: hsl(120, 100%, 40%);">+ * Osmocom Inter-Thread queue implementation */</span><br><span style="color: hsl(120, 100%, 40%);">+/* (C) 2019 by Harald Welte <laforge@gnumonks.org></span><br><span style="color: hsl(120, 100%, 40%);">+ * All Rights Reserved.</span><br><span style="color: hsl(120, 100%, 40%);">+ *</span><br><span style="color: hsl(120, 100%, 40%);">+ * SPDX-License-Identifier: GPL-2.0+</span><br><span style="color: hsl(120, 100%, 40%);">+ *</span><br><span style="color: hsl(120, 100%, 40%);">+ *  This program is free software; you can redistribute it and/or modify</span><br><span style="color: hsl(120, 100%, 40%);">+ *  it under the terms of the GNU General Public License as published by</span><br><span style="color: hsl(120, 100%, 40%);">+ *  the Free Software Foundation; either version 2 of the License, or</span><br><span style="color: hsl(120, 100%, 40%);">+ *  (at your option) any later version.</span><br><span style="color: hsl(120, 100%, 40%);">+ *</span><br><span style="color: hsl(120, 100%, 40%);">+ *  This program is distributed in the hope that it will be useful,</span><br><span style="color: hsl(120, 100%, 40%);">+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of</span><br><span style="color: hsl(120, 100%, 40%);">+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the</span><br><span style="color: hsl(120, 100%, 40%);">+ *  GNU General Public License for more details.</span><br><span style="color: hsl(120, 100%, 40%);">+ *</span><br><span style="color: hsl(120, 100%, 40%);">+ *  You should have received a copy of the GNU General Public License</span><br><span style="color: hsl(120, 100%, 40%);">+ *  along with this program; if not, write to the Free Software</span><br><span style="color: hsl(120, 100%, 40%);">+ *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,</span><br><span style="color: hsl(120, 100%, 40%);">+ *  MA  02110-1301, USA.</span><br><span style="color: hsl(120, 100%, 40%);">+ */</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+/*! \addtogroup it_q</span><br><span style="color: hsl(120, 100%, 40%);">+ *  @{</span><br><span style="color: hsl(120, 100%, 40%);">+ *  Inter-Thread Message Queue.</span><br><span style="color: hsl(120, 100%, 40%);">+ *</span><br><span style="color: hsl(120, 100%, 40%);">+ * This implements a general-purpose queue between threads. It uses</span><br><span style="color: hsl(120, 100%, 40%);">+ * user-provided data types (containing a llist_head as initial member)</span><br><span style="color: hsl(120, 100%, 40%);">+ * as elements in the queue and an eventfd-based notification mechanism.</span><br><span style="color: hsl(120, 100%, 40%);">+ * Hence, it can be used for pretty much anything, including but not</span><br><span style="color: hsl(120, 100%, 40%);">+ * limited to msgbs, including msgb-wrapped osmo_prim.</span><br><span style="color: hsl(120, 100%, 40%);">+ *</span><br><span style="color: hsl(120, 100%, 40%);">+ * The idea is that the sending thread simply calls osmo_it_q_enqueue().</span><br><span style="color: hsl(120, 100%, 40%);">+ * The receiving thread is woken up from its osmo_select_main() loop by eventfd,</span><br><span style="color: hsl(120, 100%, 40%);">+ * and a general osmo_fd callback function for the eventfd will dequeue each item</span><br><span style="color: hsl(120, 100%, 40%);">+ * and call a queue-specific callback function.</span><br><span style="color: hsl(120, 100%, 40%);">+ */</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+#include "../config.h"</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+#ifdef HAVE_SYS_EVENTFD_H</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+#include <pthread.h></span><br><span style="color: hsl(120, 100%, 40%);">+#include <unistd.h></span><br><span style="color: hsl(120, 100%, 40%);">+#include <string.h></span><br><span style="color: hsl(120, 100%, 40%);">+#include <errno.h></span><br><span style="color: hsl(120, 100%, 40%);">+#include <sys/eventfd.h></span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+#include <osmocom/core/linuxlist.h></span><br><span style="color: hsl(120, 100%, 40%);">+#include <osmocom/core/talloc.h></span><br><span style="color: hsl(120, 100%, 40%);">+#include <osmocom/core/utils.h></span><br><span style="color: hsl(120, 100%, 40%);">+#include <osmocom/core/it_q.h></span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+/* "increment" the eventfd by specified 'inc' */</span><br><span style="color: hsl(120, 100%, 40%);">+static int eventfd_increment(int fd, uint64_t inc)</span><br><span style="color: hsl(120, 100%, 40%);">+{</span><br><span style="color: hsl(120, 100%, 40%);">+    int rc;</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+     rc = write(fd, &inc, sizeof(inc));</span><br><span style="color: hsl(120, 100%, 40%);">+        if (rc != sizeof(inc))</span><br><span style="color: hsl(120, 100%, 40%);">+                return -1;</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+  return 0;</span><br><span style="color: hsl(120, 100%, 40%);">+}</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+/* global (for all threads) list of message queues in a program + associated lock */</span><br><span style="color: hsl(120, 100%, 40%);">+static LLIST_HEAD(it_queues);</span><br><span style="color: hsl(120, 100%, 40%);">+static pthread_rwlock_t it_queues_rwlock;</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+/* resolve it-queue by its [globally unique] name; must be called with rwlock held */</span><br><span style="color: hsl(120, 100%, 40%);">+static struct osmo_it_q *_osmo_it_q_by_name(const char *name)</span><br><span style="color: hsl(120, 100%, 40%);">+{</span><br><span style="color: hsl(120, 100%, 40%);">+     struct osmo_it_q *q;</span><br><span style="color: hsl(120, 100%, 40%);">+  llist_for_each_entry(q, &it_queues, entry) {</span><br><span style="color: hsl(120, 100%, 40%);">+              if (!strcmp(q->name, name))</span><br><span style="color: hsl(120, 100%, 40%);">+                        return q;</span><br><span style="color: hsl(120, 100%, 40%);">+     }</span><br><span style="color: hsl(120, 100%, 40%);">+     return NULL;</span><br><span style="color: hsl(120, 100%, 40%);">+}</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+/*! resolve it-queue by its [globally unique] name */</span><br><span style="color: hsl(120, 100%, 40%);">+struct osmo_it_q *osmo_it_q_by_name(const char *name)</span><br><span style="color: hsl(120, 100%, 40%);">+{</span><br><span style="color: hsl(120, 100%, 40%);">+    struct osmo_it_q *q;</span><br><span style="color: hsl(120, 100%, 40%);">+  pthread_rwlock_rdlock(&it_queues_rwlock);</span><br><span style="color: hsl(120, 100%, 40%);">+ q = _osmo_it_q_by_name(name);</span><br><span style="color: hsl(120, 100%, 40%);">+ pthread_rwlock_unlock(&it_queues_rwlock);</span><br><span style="color: hsl(120, 100%, 40%);">+ return q;</span><br><span style="color: hsl(120, 100%, 40%);">+}</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+/* osmo_fd call-back when eventfd is readable */</span><br><span style="color: hsl(120, 100%, 40%);">+static int osmo_it_q_fd_cb(struct osmo_fd *ofd, unsigned int what)</span><br><span style="color: hsl(120, 100%, 40%);">+{</span><br><span style="color: hsl(120, 100%, 40%);">+       struct osmo_it_q *q = (struct osmo_it_q *) ofd->data;</span><br><span style="color: hsl(120, 100%, 40%);">+      uint64_t val;</span><br><span style="color: hsl(120, 100%, 40%);">+ int i, rc;</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+  if (!(what & OSMO_FD_READ))</span><br><span style="color: hsl(120, 100%, 40%);">+               return 0;</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+   rc = read(ofd->fd, &val, sizeof(val));</span><br><span style="color: hsl(120, 100%, 40%);">+ if (rc < sizeof(val))</span><br><span style="color: hsl(120, 100%, 40%);">+              return rc;</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+  for (i = 0; i < val; i++) {</span><br><span style="color: hsl(120, 100%, 40%);">+                struct llist_head *item = _osmo_it_q_dequeue(q);</span><br><span style="color: hsl(120, 100%, 40%);">+              /* in case the user might have called osmo_it_q_flush() we may</span><br><span style="color: hsl(120, 100%, 40%);">+                 * end up in the eventfd-dispatch but without any messages left in the queue,</span><br><span style="color: hsl(120, 100%, 40%);">+          * otherwise I'd have loved to OSMO_ASSERT(msg) here. */</span><br><span style="color: hsl(120, 100%, 40%);">+          if (!item)</span><br><span style="color: hsl(120, 100%, 40%);">+                    break;</span><br><span style="color: hsl(120, 100%, 40%);">+                q->read_cb(q, item);</span><br><span style="color: hsl(120, 100%, 40%);">+       }</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+   return 0;</span><br><span style="color: hsl(120, 100%, 40%);">+}</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+/*! Allocate a new inter-thread message queue.</span><br><span style="color: hsl(120, 100%, 40%);">+ *  \param[in] ctx talloc context from which to allocate the queue</span><br><span style="color: hsl(120, 100%, 40%);">+ *  \param[in] name human-readable string name of the queue; function creates a copy.</span><br><span style="color: hsl(120, 100%, 40%);">+ *  \param[in] read_cb call-back function to be called for each de-queued message; may be</span><br><span style="color: hsl(120, 100%, 40%);">+ *                        NULL in case you don't want eventfd/osmo_select integration and</span><br><span style="color: hsl(120, 100%, 40%);">+ *                         will manually take care of noticing if and when to dequeue.</span><br><span style="color: hsl(120, 100%, 40%);">+ *  \returns a newly-allocated inter-thread message queue; NULL in case of error */</span><br><span style="color: hsl(120, 100%, 40%);">+struct osmo_it_q *osmo_it_q_alloc(void *ctx, const char *name, unsigned int max_length,</span><br><span style="color: hsl(120, 100%, 40%);">+                                     void (*read_cb)(struct osmo_it_q *q, void *item),</span><br><span style="color: hsl(120, 100%, 40%);">+                                     void *data)</span><br><span style="color: hsl(120, 100%, 40%);">+{</span><br><span style="color: hsl(120, 100%, 40%);">+        struct osmo_it_q *q;</span><br><span style="color: hsl(120, 100%, 40%);">+  int fd;</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+     q = talloc_zero(ctx, struct osmo_it_q);</span><br><span style="color: hsl(120, 100%, 40%);">+       if (!q)</span><br><span style="color: hsl(120, 100%, 40%);">+               return NULL;</span><br><span style="color: hsl(120, 100%, 40%);">+  q->data = data;</span><br><span style="color: hsl(120, 100%, 40%);">+    q->name = talloc_strdup(q, name);</span><br><span style="color: hsl(120, 100%, 40%);">+  q->current_length = 0;</span><br><span style="color: hsl(120, 100%, 40%);">+     q->max_length = max_length;</span><br><span style="color: hsl(120, 100%, 40%);">+        q->read_cb = read_cb;</span><br><span style="color: hsl(120, 100%, 40%);">+      INIT_LLIST_HEAD(&q->list);</span><br><span style="color: hsl(120, 100%, 40%);">+     q->event_ofd.fd = -1;</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+    if (q->read_cb) {</span><br><span style="color: hsl(120, 100%, 40%);">+          /* create eventfd *if* the user has provided a read_cb function */</span><br><span style="color: hsl(120, 100%, 40%);">+            fd = eventfd(0, 0);</span><br><span style="color: hsl(120, 100%, 40%);">+           if (fd < 0) {</span><br><span style="color: hsl(120, 100%, 40%);">+                      talloc_free(q);</span><br><span style="color: hsl(120, 100%, 40%);">+                       return NULL;</span><br><span style="color: hsl(120, 100%, 40%);">+          }</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+           /* initialize BUT NOT REGISTER the osmo_fd. The receiving thread must</span><br><span style="color: hsl(120, 100%, 40%);">+          * take are to select/poll/read/... on it */</span><br><span style="color: hsl(120, 100%, 40%);">+          osmo_fd_setup(&q->event_ofd, fd, OSMO_FD_READ, osmo_it_q_fd_cb, q, 0);</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+   /* add to global list of queues, checking for duplicate names */</span><br><span style="color: hsl(120, 100%, 40%);">+      pthread_rwlock_wrlock(&it_queues_rwlock);</span><br><span style="color: hsl(120, 100%, 40%);">+ if (_osmo_it_q_by_name(q->name)) {</span><br><span style="color: hsl(120, 100%, 40%);">+         pthread_rwlock_unlock(&it_queues_rwlock);</span><br><span style="color: hsl(120, 100%, 40%);">+         if (q->event_ofd.fd >= 0)</span><br><span style="color: hsl(120, 100%, 40%);">+                       osmo_fd_close(&q->event_ofd);</span><br><span style="color: hsl(120, 100%, 40%);">+          talloc_free(q);</span><br><span style="color: hsl(120, 100%, 40%);">+               return NULL;</span><br><span style="color: hsl(120, 100%, 40%);">+  }</span><br><span style="color: hsl(120, 100%, 40%);">+     llist_add_tail(&q->entry, &it_queues);</span><br><span style="color: hsl(120, 100%, 40%);">+     pthread_rwlock_unlock(&it_queues_rwlock);</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+       return q;</span><br><span style="color: hsl(120, 100%, 40%);">+}</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+static void *item_dequeue(struct llist_head *queue)</span><br><span style="color: hsl(120, 100%, 40%);">+{</span><br><span style="color: hsl(120, 100%, 40%);">+        struct llist_head *lh;</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+      if (llist_empty(queue))</span><br><span style="color: hsl(120, 100%, 40%);">+               return NULL;</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+        lh = queue->next;</span><br><span style="color: hsl(120, 100%, 40%);">+  if (lh) {</span><br><span style="color: hsl(120, 100%, 40%);">+             llist_del(lh);</span><br><span style="color: hsl(120, 100%, 40%);">+                return lh;</span><br><span style="color: hsl(120, 100%, 40%);">+    } else</span><br><span style="color: hsl(120, 100%, 40%);">+                return NULL;</span><br><span style="color: hsl(120, 100%, 40%);">+}</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+/*! Flush all messages currently present in queue */</span><br><span style="color: hsl(120, 100%, 40%);">+static void _osmo_it_q_flush(struct osmo_it_q *q)</span><br><span style="color: hsl(120, 100%, 40%);">+{</span><br><span style="color: hsl(120, 100%, 40%);">+ void *item;</span><br><span style="color: hsl(120, 100%, 40%);">+   while ((item = item_dequeue(&q->list))) {</span><br><span style="color: hsl(120, 100%, 40%);">+              talloc_free(item);</span><br><span style="color: hsl(120, 100%, 40%);">+    }</span><br><span style="color: hsl(120, 100%, 40%);">+     q->current_length = 0;</span><br><span style="color: hsl(120, 100%, 40%);">+}</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+/*! Flush all messages currently present in queue */</span><br><span style="color: hsl(120, 100%, 40%);">+void osmo_it_q_flush(struct osmo_it_q *q)</span><br><span style="color: hsl(120, 100%, 40%);">+{</span><br><span style="color: hsl(120, 100%, 40%);">+    OSMO_ASSERT(q);</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+     pthread_mutex_lock(&q->mutex);</span><br><span style="color: hsl(120, 100%, 40%);">+ _osmo_it_q_flush(q);</span><br><span style="color: hsl(120, 100%, 40%);">+  pthread_mutex_unlock(&q->mutex);</span><br><span style="color: hsl(120, 100%, 40%);">+}</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+/*! Destroy a message queue */</span><br><span style="color: hsl(120, 100%, 40%);">+void osmo_it_q_destroy(struct osmo_it_q *q)</span><br><span style="color: hsl(120, 100%, 40%);">+{</span><br><span style="color: hsl(120, 100%, 40%);">+  OSMO_ASSERT(q);</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+     /* first remove from global list of queues */</span><br><span style="color: hsl(120, 100%, 40%);">+ pthread_rwlock_wrlock(&it_queues_rwlock);</span><br><span style="color: hsl(120, 100%, 40%);">+ llist_del(&q->entry);</span><br><span style="color: hsl(120, 100%, 40%);">+  pthread_rwlock_unlock(&it_queues_rwlock);</span><br><span style="color: hsl(120, 100%, 40%);">+ /* next, close the eventfd */</span><br><span style="color: hsl(120, 100%, 40%);">+ if (q->event_ofd.fd >= 0)</span><br><span style="color: hsl(120, 100%, 40%);">+               osmo_fd_close(&q->event_ofd);</span><br><span style="color: hsl(120, 100%, 40%);">+  /* flush all messages still present */</span><br><span style="color: hsl(120, 100%, 40%);">+        osmo_it_q_flush(q);</span><br><span style="color: hsl(120, 100%, 40%);">+   /* and finally release memory */</span><br><span style="color: hsl(120, 100%, 40%);">+      talloc_free(q);</span><br><span style="color: hsl(120, 100%, 40%);">+}</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+/*! Thread-safe en-queue to an inter-thread message queue.</span><br><span style="color: hsl(120, 100%, 40%);">+ *  \param[in] queue Inter-thread queue on which to enqueue</span><br><span style="color: hsl(120, 100%, 40%);">+ *  \param[in] item Item to enqueue. Must have llist_head as first member!</span><br><span style="color: hsl(120, 100%, 40%);">+ *  \returns 0 on success; negative on error */</span><br><span style="color: hsl(120, 100%, 40%);">+int _osmo_it_q_enqueue(struct osmo_it_q *queue, struct llist_head *item)</span><br><span style="color: hsl(120, 100%, 40%);">+{</span><br><span style="color: hsl(120, 100%, 40%);">+       OSMO_ASSERT(queue);</span><br><span style="color: hsl(120, 100%, 40%);">+   OSMO_ASSERT(item);</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+  pthread_mutex_lock(&queue->mutex);</span><br><span style="color: hsl(120, 100%, 40%);">+     if (queue->current_length+1 > queue->max_length) {</span><br><span style="color: hsl(120, 100%, 40%);">+           pthread_mutex_unlock(&queue->mutex);</span><br><span style="color: hsl(120, 100%, 40%);">+           return -ENOSPC;</span><br><span style="color: hsl(120, 100%, 40%);">+       }</span><br><span style="color: hsl(120, 100%, 40%);">+     llist_add_tail(item, &queue->list);</span><br><span style="color: hsl(120, 100%, 40%);">+    queue->current_length++;</span><br><span style="color: hsl(120, 100%, 40%);">+   pthread_mutex_unlock(&queue->mutex);</span><br><span style="color: hsl(120, 100%, 40%);">+   /* increment eventfd counter by one */</span><br><span style="color: hsl(120, 100%, 40%);">+        if (queue->event_ofd.fd >= 0)</span><br><span style="color: hsl(120, 100%, 40%);">+           eventfd_increment(queue->event_ofd.fd, 1);</span><br><span style="color: hsl(120, 100%, 40%);">+ return 0;</span><br><span style="color: hsl(120, 100%, 40%);">+}</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+/*! Thread-safe de-queue from an inter-thread message queue.</span><br><span style="color: hsl(120, 100%, 40%);">+ *  \param[in] queue Inter-thread queue from which to dequeue</span><br><span style="color: hsl(120, 100%, 40%);">+ *  \returns dequeued message buffer; NULL if none available</span><br><span style="color: hsl(120, 100%, 40%);">+ */</span><br><span style="color: hsl(120, 100%, 40%);">+struct llist_head *_osmo_it_q_dequeue(struct osmo_it_q *queue)</span><br><span style="color: hsl(120, 100%, 40%);">+{</span><br><span style="color: hsl(120, 100%, 40%);">+   struct llist_head *l;</span><br><span style="color: hsl(120, 100%, 40%);">+ OSMO_ASSERT(queue);</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ pthread_mutex_lock(&queue->mutex);</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+   if (llist_empty(&queue->list))</span><br><span style="color: hsl(120, 100%, 40%);">+         l = NULL;</span><br><span style="color: hsl(120, 100%, 40%);">+     l = queue->list.next;</span><br><span style="color: hsl(120, 100%, 40%);">+      OSMO_ASSERT(l);</span><br><span style="color: hsl(120, 100%, 40%);">+       llist_del(l);</span><br><span style="color: hsl(120, 100%, 40%);">+ queue->current_length--;</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ pthread_mutex_unlock(&queue->mutex);</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ return l;</span><br><span style="color: hsl(120, 100%, 40%);">+}</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+#endif /* HAVE_SYS_EVENTFD_H */</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+/*! @} */</span><br><span>diff --git a/tests/Makefile.am b/tests/Makefile.am</span><br><span>index dbca9d7..b3832e8 100644</span><br><span>--- a/tests/Makefile.am</span><br><span>+++ b/tests/Makefile.am</span><br><span>@@ -41,6 +41,7 @@</span><br><span>           gad/gad_test                                           \</span><br><span>             bsslap/bsslap_test                                     \</span><br><span>             bssmap_le/bssmap_le_test                               \</span><br><span style="color: hsl(120, 100%, 40%);">+              it_q/it_q_test                                         \</span><br><span>             $(NULL)</span><br><span> </span><br><span> if ENABLE_MSGFILE</span><br><span>@@ -294,6 +295,9 @@</span><br><span> bssmap_le_bssmap_le_test_SOURCES = bssmap_le/bssmap_le_test.c</span><br><span> bssmap_le_bssmap_le_test_LDADD = $(LDADD) $(top_builddir)/src/gsm/libosmogsm.la</span><br><span> </span><br><span style="color: hsl(120, 100%, 40%);">+it_q_it_q_test_SOURCES = it_q/it_q_test.c</span><br><span style="color: hsl(120, 100%, 40%);">+it_q_it_q_test_LDADD = $(LDADD)</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span> # The `:;' works around a Bash 3.2 bug when the output is not writeable.</span><br><span> $(srcdir)/package.m4: $(top_srcdir)/configure.ac</span><br><span>    :;{ \</span><br><span>@@ -378,6 +382,7 @@</span><br><span>       gad/gad_test.ok \</span><br><span>            bsslap/bsslap_test.ok \</span><br><span>              bssmap_le/bssmap_le_test.ok \</span><br><span style="color: hsl(120, 100%, 40%);">+         it_q/it_q_test.ok \</span><br><span>          $(NULL)</span><br><span> </span><br><span> if ENABLE_LIBSCTP</span><br><span>diff --git a/tests/it_q/it_q_test.c b/tests/it_q/it_q_test.c</span><br><span>new file mode 100644</span><br><span>index 0000000..b08c46c</span><br><span>--- /dev/null</span><br><span>+++ b/tests/it_q/it_q_test.c</span><br><span>@@ -0,0 +1,117 @@</span><br><span style="color: hsl(120, 100%, 40%);">+#include <stdio.h></span><br><span style="color: hsl(120, 100%, 40%);">+#include <errno.h></span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+#include <osmocom/core/talloc.h></span><br><span style="color: hsl(120, 100%, 40%);">+#include <osmocom/core/utils.h></span><br><span style="color: hsl(120, 100%, 40%);">+#include <osmocom/core/it_q.h></span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+struct it_q_test1 {</span><br><span style="color: hsl(120, 100%, 40%);">+     struct llist_head list;</span><br><span style="color: hsl(120, 100%, 40%);">+       int foo;</span><br><span style="color: hsl(120, 100%, 40%);">+};</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+struct it_q_test2 {</span><br><span style="color: hsl(120, 100%, 40%);">+   int foo;</span><br><span style="color: hsl(120, 100%, 40%);">+      struct llist_head list;</span><br><span style="color: hsl(120, 100%, 40%);">+};</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+#define ENTER_TC printf("\n== Entering test case %s\n", __func__)</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+static void tc_alloc(void)</span><br><span style="color: hsl(120, 100%, 40%);">+{</span><br><span style="color: hsl(120, 100%, 40%);">+   struct osmo_it_q *q1, *q2;</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+  ENTER_TC;</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+   printf("allocating q1\n");</span><br><span style="color: hsl(120, 100%, 40%);">+  q1 = osmo_it_q_alloc(OTC_GLOBAL, "q1", 3, NULL, NULL);</span><br><span style="color: hsl(120, 100%, 40%);">+      OSMO_ASSERT(q1);</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+    /* ensure that no duplicate allocation for the */</span><br><span style="color: hsl(120, 100%, 40%);">+     printf("attempting duplicate allocation of qa\n");</span><br><span style="color: hsl(120, 100%, 40%);">+  q2 = osmo_it_q_alloc(OTC_GLOBAL, "q1", 3, NULL, NULL);</span><br><span style="color: hsl(120, 100%, 40%);">+      OSMO_ASSERT(!q2);</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+   /* ensure that same name can be re-created after destroying old one */</span><br><span style="color: hsl(120, 100%, 40%);">+        osmo_it_q_destroy(q1);</span><br><span style="color: hsl(120, 100%, 40%);">+        printf("re-allocating q1\n");</span><br><span style="color: hsl(120, 100%, 40%);">+       q1 = osmo_it_q_alloc(OTC_GLOBAL, "q1", 3, NULL, NULL);</span><br><span style="color: hsl(120, 100%, 40%);">+      OSMO_ASSERT(q1);</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+    osmo_it_q_destroy(q1);</span><br><span style="color: hsl(120, 100%, 40%);">+}</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+static void tc_queue_length(void)</span><br><span style="color: hsl(120, 100%, 40%);">+{</span><br><span style="color: hsl(120, 100%, 40%);">+     struct osmo_it_q *q1;</span><br><span style="color: hsl(120, 100%, 40%);">+ unsigned int qlen = 3;</span><br><span style="color: hsl(120, 100%, 40%);">+        struct it_q_test1 *item;</span><br><span style="color: hsl(120, 100%, 40%);">+      int i, rc;</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+  ENTER_TC;</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+   printf("allocating q1\n");</span><br><span style="color: hsl(120, 100%, 40%);">+  q1 = osmo_it_q_alloc(OTC_GLOBAL, "q1", qlen, NULL, NULL);</span><br><span style="color: hsl(120, 100%, 40%);">+   OSMO_ASSERT(q1);</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+    printf("adding queue entries up to the limit\n");</span><br><span style="color: hsl(120, 100%, 40%);">+   for (i = 0; i < qlen; i++) {</span><br><span style="color: hsl(120, 100%, 40%);">+               item = talloc_zero(OTC_GLOBAL, struct it_q_test1);</span><br><span style="color: hsl(120, 100%, 40%);">+            rc = osmo_it_q_enqueue(q1, item, list);</span><br><span style="color: hsl(120, 100%, 40%);">+               OSMO_ASSERT(rc == 0);</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span style="color: hsl(120, 100%, 40%);">+     printf("attempting to add more than the limit\n");</span><br><span style="color: hsl(120, 100%, 40%);">+  item = talloc_zero(OTC_GLOBAL, struct it_q_test1);</span><br><span style="color: hsl(120, 100%, 40%);">+    rc = osmo_it_q_enqueue(q1, item, list);</span><br><span style="color: hsl(120, 100%, 40%);">+       OSMO_ASSERT(rc == -ENOSPC);</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ osmo_it_q_destroy(q1);</span><br><span style="color: hsl(120, 100%, 40%);">+}</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+static int g_read_cb_count;</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+static void q_read_cb(struct osmo_it_q *q, void *item)</span><br><span style="color: hsl(120, 100%, 40%);">+{</span><br><span style="color: hsl(120, 100%, 40%);">+ g_read_cb_count++;</span><br><span style="color: hsl(120, 100%, 40%);">+    talloc_free(item);</span><br><span style="color: hsl(120, 100%, 40%);">+}</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+static void tc_eventfd(void)</span><br><span style="color: hsl(120, 100%, 40%);">+{</span><br><span style="color: hsl(120, 100%, 40%);">+      struct osmo_it_q *q1;</span><br><span style="color: hsl(120, 100%, 40%);">+ unsigned int qlen = 30;</span><br><span style="color: hsl(120, 100%, 40%);">+       struct it_q_test1 *item;</span><br><span style="color: hsl(120, 100%, 40%);">+      int i, rc;</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+  ENTER_TC;</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+   printf("allocating q1\n");</span><br><span style="color: hsl(120, 100%, 40%);">+  q1 = osmo_it_q_alloc(OTC_GLOBAL, "q1", qlen, q_read_cb, NULL);</span><br><span style="color: hsl(120, 100%, 40%);">+      OSMO_ASSERT(q1);</span><br><span style="color: hsl(120, 100%, 40%);">+      osmo_fd_register(&q1->event_ofd);</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+    /* ensure read-cb isn't called unless we enqueue something */</span><br><span style="color: hsl(120, 100%, 40%);">+     osmo_select_main(1);</span><br><span style="color: hsl(120, 100%, 40%);">+  OSMO_ASSERT(g_read_cb_count == 0);</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+  /* ensure read-cb is called for each enqueued msg once */</span><br><span style="color: hsl(120, 100%, 40%);">+     printf("adding %u queue entries up to the limit\n", qlen);</span><br><span style="color: hsl(120, 100%, 40%);">+  for (i = 0; i < qlen; i++) {</span><br><span style="color: hsl(120, 100%, 40%);">+               item = talloc_zero(OTC_GLOBAL, struct it_q_test1);</span><br><span style="color: hsl(120, 100%, 40%);">+            rc = osmo_it_q_enqueue(q1, item, list);</span><br><span style="color: hsl(120, 100%, 40%);">+               OSMO_ASSERT(rc == 0);</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+   osmo_select_main(1);</span><br><span style="color: hsl(120, 100%, 40%);">+  printf("%u entries were dequeued\n", qlen);</span><br><span style="color: hsl(120, 100%, 40%);">+ OSMO_ASSERT(g_read_cb_count == qlen);</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+       osmo_it_q_destroy(q1);</span><br><span style="color: hsl(120, 100%, 40%);">+}</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+int main(int argc, char **argv)</span><br><span style="color: hsl(120, 100%, 40%);">+{</span><br><span style="color: hsl(120, 100%, 40%);">+       tc_alloc();</span><br><span style="color: hsl(120, 100%, 40%);">+   tc_queue_length();</span><br><span style="color: hsl(120, 100%, 40%);">+    tc_eventfd();</span><br><span style="color: hsl(120, 100%, 40%);">+}</span><br><span>diff --git a/tests/it_q/it_q_test.ok b/tests/it_q/it_q_test.ok</span><br><span>new file mode 100644</span><br><span>index 0000000..7f102c6</span><br><span>--- /dev/null</span><br><span>+++ b/tests/it_q/it_q_test.ok</span><br><span>@@ -0,0 +1,15 @@</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+== Entering test case tc_alloc</span><br><span style="color: hsl(120, 100%, 40%);">+allocating q1</span><br><span style="color: hsl(120, 100%, 40%);">+attempting duplicate allocation of qa</span><br><span style="color: hsl(120, 100%, 40%);">+re-allocating q1</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+== Entering test case tc_queue_length</span><br><span style="color: hsl(120, 100%, 40%);">+allocating q1</span><br><span style="color: hsl(120, 100%, 40%);">+adding queue entries up to the limit</span><br><span style="color: hsl(120, 100%, 40%);">+attempting to add more than the limit</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+== Entering test case tc_eventfd</span><br><span style="color: hsl(120, 100%, 40%);">+allocating q1</span><br><span style="color: hsl(120, 100%, 40%);">+adding 30 queue entries up to the limit</span><br><span style="color: hsl(120, 100%, 40%);">+30 entries were dequeued</span><br><span>diff --git a/tests/testsuite.at b/tests/testsuite.at</span><br><span>index 43f515a..1a3b2fb 100644</span><br><span>--- a/tests/testsuite.at</span><br><span>+++ b/tests/testsuite.at</span><br><span>@@ -420,4 +420,9 @@</span><br><span> AT_KEYWORDS([bssmap_le])</span><br><span> cat $abs_srcdir/bssmap_le/bssmap_le_test.ok > expout</span><br><span> AT_CHECK([$abs_top_builddir/tests/bssmap_le/bssmap_le_test], [0], [expout], [ignore])</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+AT_SETUP([it_q])</span><br><span style="color: hsl(120, 100%, 40%);">+AT_KEYWORDS([it_q])</span><br><span style="color: hsl(120, 100%, 40%);">+cat $abs_srcdir/it_q/it_q_test.ok > expout</span><br><span style="color: hsl(120, 100%, 40%);">+AT_CHECK([$abs_top_builddir/tests/it_q/it_q_test], [0], [expout], [ignore])</span><br><span> AT_CLEANUP</span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.osmocom.org/c/libosmocore/+/21930">change 21930</a>. To unsubscribe, or for help writing mail filters, visit <a href="https://gerrit.osmocom.org/settings">settings</a>.</p><div itemscope itemtype="http://schema.org/EmailMessage"><div itemscope itemprop="action" itemtype="http://schema.org/ViewAction"><link itemprop="url" href="https://gerrit.osmocom.org/c/libosmocore/+/21930"/><meta itemprop="name" content="View Change"/></div></div>

<div style="display:none"> Gerrit-Project: libosmocore </div>
<div style="display:none"> Gerrit-Branch: master </div>
<div style="display:none"> Gerrit-Change-Id: Ie7d0c5fec715a2a577fae014b0b8a0e9c38418ef </div>
<div style="display:none"> Gerrit-Change-Number: 21930 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: laforge <laforge@osmocom.org> </div>
<div style="display:none"> Gerrit-MessageType: newchange </div>