mirror of https://gerrit.osmocom.org/libosmocore
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
This commit is contained in:
parent
f44937834f
commit
c433889bba
|
@ -68,10 +68,15 @@ int osmo_wqueue_bfd_cb(struct osmo_fd *fd, unsigned int what)
|
|||
/* 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;
|
||||
|
|
Loading…
Reference in New Issue