From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1O4BhE-0000Zf-SU for qemu-devel@nongnu.org; Tue, 20 Apr 2010 07:32:52 -0400 Received: from [140.186.70.92] (port=32936 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1O4BhD-0000XJ-2n for qemu-devel@nongnu.org; Tue, 20 Apr 2010 07:32:52 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1O4Bh8-0001g3-KS for qemu-devel@nongnu.org; Tue, 20 Apr 2010 07:32:50 -0400 Received: from mx1.redhat.com ([209.132.183.28]:55359) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1O4Bh7-0001fh-S7 for qemu-devel@nongnu.org; Tue, 20 Apr 2010 07:32:46 -0400 Message-ID: <4BCD90C2.7050009@redhat.com> Date: Tue, 20 Apr 2010 13:32:18 +0200 From: Gerd Hoffmann MIME-Version: 1.0 Subject: Re: [Qemu-devel] [PATCH v3 2/4] char: Add ability to provide a callback when write won't return -EAGAIN References: <1271319378-9811-1-git-send-email-amit.shah@redhat.com> <1271319378-9811-2-git-send-email-amit.shah@redhat.com> <1271319378-9811-3-git-send-email-amit.shah@redhat.com> In-Reply-To: <1271319378-9811-3-git-send-email-amit.shah@redhat.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Amit Shah Cc: qemu list , paul@codesourcery.com > 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