Change in libosmocore[master]: write_queue: Re-enqueue msgb if write_cb returns -EAGAIN

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.

laforge gerrit-no-reply at lists.osmocom.org
Sun Sep 27 14:58:12 UTC 2020


laforge has uploaded this change for review. ( https://gerrit.osmocom.org/c/libosmocore/+/20302 )


Change subject: write_queue: Re-enqueue msgb if write_cb returns -EAGAIN
......................................................................

write_queue: Re-enqueue msgb if write_cb returns -EAGAIN

By adding this functionality, the write_cb() handler can "un-dequeue"
the msgb in case of some error.  The msgb might have been modified
meanwhile, e.g. due to a partial write already pulling some data off
the head of the msgb.

Change-Id: I97bb0d64ec991adf5dd0b3708e0c7cf029e03b5f
---
M src/write_queue.c
1 file changed, 8 insertions(+), 3 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/02/20302/1

diff --git a/src/write_queue.c b/src/write_queue.c
index 422eda4..b208b25 100644
--- a/src/write_queue.c
+++ b/src/write_queue.c
@@ -68,10 +68,15 @@
 		/* the queue might have been emptied */
 		if (msg) {
 			rc = queue->write_cb(fd, msg);
-			msgb_free(msg);
-
-			if (rc == -EBADF)
+			if (rc == -EBADF) {
+				msgb_free(msg);
 				goto err_badfd;
+			} else if (rc == -EAGAIN) {
+				/* re-enqueue the msgb to the head of the queue */
+				llist_add(&msg->list, &queue->msg_queue);
+				queue->current_length++;
+			} else
+				msgb_free(msg);
 
 			if (!llist_empty(&queue->msg_queue))
 				fd->when |= OSMO_FD_WRITE;

-- 
To view, visit https://gerrit.osmocom.org/c/libosmocore/+/20302
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Change-Id: I97bb0d64ec991adf5dd0b3708e0c7cf029e03b5f
Gerrit-Change-Number: 20302
Gerrit-PatchSet: 1
Gerrit-Owner: laforge <laforge at osmocom.org>
Gerrit-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20200927/7d5b683b/attachment.htm>


More information about the gerrit-log mailing list