<p>laforge has uploaded this change for <strong>review</strong>.</p><p><a href="https://gerrit.osmocom.org/c/libosmocore/+/20302">View Change</a></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">write_queue: Re-enqueue msgb if write_cb returns -EAGAIN<br><br>By adding this functionality, the write_cb() handler can "un-dequeue"<br>the msgb in case of some error.  The msgb might have been modified<br>meanwhile, e.g. due to a partial write already pulling some data off<br>the head of the msgb.<br><br>Change-Id: I97bb0d64ec991adf5dd0b3708e0c7cf029e03b5f<br>---<br>M src/write_queue.c<br>1 file changed, 8 insertions(+), 3 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/02/20302/1</pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/src/write_queue.c b/src/write_queue.c</span><br><span>index 422eda4..b208b25 100644</span><br><span>--- a/src/write_queue.c</span><br><span>+++ b/src/write_queue.c</span><br><span>@@ -68,10 +68,15 @@</span><br><span>              /* the queue might have been emptied */</span><br><span>              if (msg) {</span><br><span>                   rc = queue->write_cb(fd, msg);</span><br><span style="color: hsl(0, 100%, 40%);">-                       msgb_free(msg);</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-                 if (rc == -EBADF)</span><br><span style="color: hsl(120, 100%, 40%);">+                     if (rc == -EBADF) {</span><br><span style="color: hsl(120, 100%, 40%);">+                           msgb_free(msg);</span><br><span>                              goto err_badfd;</span><br><span style="color: hsl(120, 100%, 40%);">+                       } else if (rc == -EAGAIN) {</span><br><span style="color: hsl(120, 100%, 40%);">+                           /* re-enqueue the msgb to the head of the queue */</span><br><span style="color: hsl(120, 100%, 40%);">+                            llist_add(&msg->list, &queue->msg_queue);</span><br><span style="color: hsl(120, 100%, 40%);">+                               queue->current_length++;</span><br><span style="color: hsl(120, 100%, 40%);">+                   } else</span><br><span style="color: hsl(120, 100%, 40%);">+                                msgb_free(msg);</span><br><span> </span><br><span>                  if (!llist_empty(&queue->msg_queue))</span><br><span>                          fd->when |= OSMO_FD_WRITE;</span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.osmocom.org/c/libosmocore/+/20302">change 20302</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/+/20302"/><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: I97bb0d64ec991adf5dd0b3708e0c7cf029e03b5f </div>
<div style="display:none"> Gerrit-Change-Number: 20302 </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>