- while (msg_queue.head && io_multiplexing_out) {
- struct msg_list_item *m = msg_queue.head;
- int len = IVAL(m->buf, 0) & 0xFFFFFF;
- int tag = *((uchar*)m->buf+3) - MPLEX_BASE;
- if (!(msg_queue.head = m->next))
- msg_queue.tail = NULL;
- stats.total_written += len + 4;
- defer_forwarding_messages++;
- mplex_write(sock_f_out, tag, m->buf + 4, len, m->convert);
- defer_forwarding_messages--;
- free(m);
- }
+ while (msg_queue.head && io_multiplexing_out)
+ stats.total_written += flush_a_msg(sock_f_out) + 4;