sercomm_cons: Utilize msgb's better, don't always end at \n
authorHarald Welte <laforge@gnumonks.org>
Sun, 21 Feb 2010 14:16:40 +0000 (15:16 +0100)
committerHarald Welte <laforge@gnumonks.org>
Sun, 21 Feb 2010 14:16:40 +0000 (15:16 +0100)
In the sercomm_cons layer, ee used to enqueue a msgb for sending
every time there is an end-of-line.  However, if we send a number
of very short lines, we easily run out of msgbs.

Now we check how much msgb backlog there is in the transmit queue,
and decide to skip the end-of-line flushing if needed.

This still doesn't solve all our problems, but its still a useful
mechanism.

src/target/firmware/comm/sercomm_cons.c

index fa08b50..5b481bc 100644 (file)
@@ -91,8 +91,11 @@ int sercomm_puts(const char *s)
                {
                        unsigned int i;
                        for (i = 0; i < write_num; i++) {
-                               /* flush buffer at end of line */
-                               if (*s == '\n')
+                               /* flush buffer at end of line, but skip
+                                * flushing if we have a backlog in order to
+                                * increase efficiency of msgb filling */
+                               if (*s == '\n' &&
+                                   sercomm_tx_queue_depth(SC_DLCI_CONSOLE) < 4)
                                        flush = 1;
                                *data++ = *s++;
                        }