aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHarald Welte <laforge@osmocom.org>2020-09-26 22:02:27 +0200
committerlaforge <laforge@osmocom.org>2020-09-29 16:30:56 +0000
commit66138ccab5bd6a830efbb2379ff229f4005e3b62 (patch)
tree35a3183ce6df8910a332ecd823b59f53f6dab5ab
parent7f6c87da2f5a78a76c3bc019d31c6473f3eb9487 (diff)
write_queue: Add osmo_wqueue_enqueue_quiet()
Same as osmo_wqueue_enqueue() but without logging queue overruns. Change-Id: Ic082eb39795b08631284eeb421fef3c28f2e90dc
-rw-r--r--include/osmocom/core/write_queue.h1
-rw-r--r--src/write_queue.c23
2 files changed, 19 insertions, 5 deletions
diff --git a/include/osmocom/core/write_queue.h b/include/osmocom/core/write_queue.h
index 071621d1..75d5d8fb 100644
--- a/include/osmocom/core/write_queue.h
+++ b/include/osmocom/core/write_queue.h
@@ -53,6 +53,7 @@ struct osmo_wqueue {
void osmo_wqueue_init(struct osmo_wqueue *queue, int max_length);
void osmo_wqueue_clear(struct osmo_wqueue *queue);
int osmo_wqueue_enqueue(struct osmo_wqueue *queue, struct msgb *data);
+int osmo_wqueue_enqueue_quiet(struct osmo_wqueue *queue, struct msgb *data);
int osmo_wqueue_bfd_cb(struct osmo_fd *fd, unsigned int what);
/*! @} */
diff --git a/src/write_queue.c b/src/write_queue.c
index 3399b0f1..c7dedc47 100644
--- a/src/write_queue.c
+++ b/src/write_queue.c
@@ -100,6 +100,23 @@ void osmo_wqueue_init(struct osmo_wqueue *queue, int max_length)
INIT_LLIST_HEAD(&queue->msg_queue);
}
+/*! Enqueue a new \ref msgb into a write queue (without logging full queue events)
+ * \param[in] queue Write queue to be used
+ * \param[in] data to-be-enqueued message buffer
+ * \returns 0 on success; negative on error
+ */
+int osmo_wqueue_enqueue_quiet(struct osmo_wqueue *queue, struct msgb *data)
+{
+ if (queue->current_length >= queue->max_length)
+ return -ENOSPC;
+
+ ++queue->current_length;
+ msgb_enqueue(&queue->msg_queue, data);
+ queue->bfd.when |= OSMO_FD_WRITE;
+
+ return 0;
+}
+
/*! Enqueue a new \ref msgb into a write queue
* \param[in] queue Write queue to be used
* \param[in] data to-be-enqueued message buffer
@@ -113,11 +130,7 @@ int osmo_wqueue_enqueue(struct osmo_wqueue *queue, struct msgb *data)
return -ENOSPC;
}
- ++queue->current_length;
- msgb_enqueue(&queue->msg_queue, data);
- queue->bfd.when |= OSMO_FD_WRITE;
-
- return 0;
+ return osmo_wqueue_enqueue_quiet(queue, data);
}
/*! Clear a \ref osmo_wqueue