- while (msg2sndr.head && io_multiplexing_out) {
- struct msg_list_item *m = msg2sndr.head;
- if (!(msg2sndr.head = m->next))
- msg2sndr.tail = NULL;
- stats.total_written += m->len;
- defer_forwarding_messages = 1;
- writefd_unbuffered(sock_f_out, m->buf, m->len);
- defer_forwarding_messages = 0;
- free(m);
+ if (am_generator) {
+ while (msg_queue.head && io_multiplexing_out) {
+ struct msg_list_item *m = msg_queue.head;
+ if (!(msg_queue.head = m->next))
+ msg_queue.tail = NULL;
+ stats.total_written += m->len;
+ defer_forwarding_messages++;
+ writefd_unbuffered(sock_f_out, m->buf, m->len);
+ defer_forwarding_messages--;
+ free(m);
+ }
+ } else {
+ while (msg_queue.head) {
+ struct msg_list_item *m = msg_queue.head;
+ if (!(msg_queue.head = m->next))
+ msg_queue.tail = NULL;
+ defer_forwarding_messages++;
+ writefd_unbuffered(msg_fd_out, m->buf, m->len);
+ defer_forwarding_messages--;
+ free(m);
+ }