|
From: | Gerd Hoffmann |
Subject: | Re: [Qemu-devel] [PATCH v3 2/4] char: Add ability to provide a callback when write won't return -EAGAIN |
Date: | Tue, 20 Apr 2010 13:32:18 +0200 |
User-agent: | Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.1.9) Gecko/20100330 Fedora/3.0.4-1.fc12 Thunderbird/3.0.4 |
static void tcp_chr_connect(void *opaque) {
+ chr->write_blocked = false; s->connected = 1; qemu_set_fd_handler2(s->fd, tcp_chr_read_poll, - tcp_chr_read, NULL, chr); + tcp_chr_read, tcp_chr_write_unblocked, chr);
This is wrong. You want register tcp_chr_write_unblocked only for the chr->write_blocked == true (i.e. output buffers are full) case. Otherwise qemu will burn cpu calling tcp_chr_write_unblocked.
Yes, you'll have to call qemu_set_fd_handler2 each time write_blocked changes state.
Also implementing the whole logic at the individual chardev drivers level feels somewhat wrong as it will identical for most (all?) unix chardev drivers.
cheers, Gerd
[Prev in Thread] | Current Thread | [Next in Thread] |