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
diff --git a/src/write_queue.c b/src/write_queue.c
index c7dedc4..422eda4 100644
--- a/src/write_queue.c
+++ b/src/write_queue.c
@@ -64,11 +64,9 @@
 
 		fd->when &= ~OSMO_FD_WRITE;
 
+		msg = msgb_dequeue_count(&queue->msg_queue, &queue->current_length);
 		/* the queue might have been emptied */
-		if (!llist_empty(&queue->msg_queue)) {
-			--queue->current_length;
-
-			msg = msgb_dequeue(&queue->msg_queue);
+		if (msg) {
 			rc = queue->write_cb(fd, msg);
 			msgb_free(msg);
 
@@ -110,8 +108,7 @@
 	if (queue->current_length >= queue->max_length)
 		return -ENOSPC;
 
-	++queue->current_length;
-	msgb_enqueue(&queue->msg_queue, data);
+	msgb_enqueue_count(&queue->msg_queue, data, &queue->current_length);
 	queue->bfd.when |= OSMO_FD_WRITE;
 
 	return 0;