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
Tue Sep 29 16:58:11 UTC 2020


laforge has submitted this change. ( 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(-)

Approvals:
  fixeria: Looks good to me, but someone else must approve
  pespin: Looks good to me, approved
  Jenkins Builder: Verified



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: 2
Gerrit-Owner: laforge <laforge at osmocom.org>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: fixeria <vyanitskiy at sysmocom.de>
Gerrit-Reviewer: laforge <laforge at osmocom.org>
Gerrit-Reviewer: pespin <pespin at sysmocom.de>
Gerrit-MessageType: merged
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20200929/5d3fbd6d/attachment.htm>


More information about the gerrit-log mailing list