write_queue: use msgb_{en,de}queue_count()

The write_queue.c implemetation predates the msgb_*queue_count()
functions for maintaining a count alongside witha msgb queue. Let's
migrate over to those implementations.

Change-Id: I0ebd42a50f239dd7e9f663ce4c42824a5c1b3ce7
This commit is contained in:
Harald Welte 2020-09-27 16:39:01 +02:00 committed by laforge
parent 66138ccab5
commit f44937834f
1 changed files with 3 additions and 6 deletions

View File

@ -64,11 +64,9 @@ int osmo_wqueue_bfd_cb(struct osmo_fd *fd, unsigned int what)
fd->when &= ~OSMO_FD_WRITE; fd->when &= ~OSMO_FD_WRITE;
msg = msgb_dequeue_count(&queue->msg_queue, &queue->current_length);
/* the queue might have been emptied */ /* the queue might have been emptied */
if (!llist_empty(&queue->msg_queue)) { if (msg) {
--queue->current_length;
msg = msgb_dequeue(&queue->msg_queue);
rc = queue->write_cb(fd, msg); rc = queue->write_cb(fd, msg);
msgb_free(msg); msgb_free(msg);
@ -110,8 +108,7 @@ int osmo_wqueue_enqueue_quiet(struct osmo_wqueue *queue, struct msgb *data)
if (queue->current_length >= queue->max_length) if (queue->current_length >= queue->max_length)
return -ENOSPC; return -ENOSPC;
++queue->current_length; msgb_enqueue_count(&queue->msg_queue, data, &queue->current_length);
msgb_enqueue(&queue->msg_queue, data);
queue->bfd.when |= OSMO_FD_WRITE; queue->bfd.when |= OSMO_FD_WRITE;
return 0; return 0;