Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1O9OCU-0007IN-0B for qemu-devel@nongnu.org; Tue, 04 May 2010 15:54:38 -0400 Received: from [140.186.70.92] (port=42884 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1O9OCS-0007GQ-KH for qemu-devel@nongnu.org; Tue, 04 May 2010 15:54:37 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1O9OCR-00087X-4O for qemu-devel@nongnu.org; Tue, 04 May 2010 15:54:36 -0400 Received: from mx1.redhat.com ([209.132.183.28]:46081) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1O9OCQ-000870-Su for qemu-devel@nongnu.org; Tue, 04 May 2010 15:54:35 -0400 From: Juan Quintela In-Reply-To: <1272997439-9675-6-git-send-email-amit.shah@redhat.com> (Amit Shah's message of "Tue, 4 May 2010 23:53:58 +0530") References: <1272997439-9675-1-git-send-email-amit.shah@redhat.com> <1272997439-9675-2-git-send-email-amit.shah@redhat.com> <1272997439-9675-3-git-send-email-amit.shah@redhat.com> <1272997439-9675-4-git-send-email-amit.shah@redhat.com> <1272997439-9675-5-git-send-email-amit.shah@redhat.com> <1272997439-9675-6-git-send-email-amit.shah@redhat.com> Date: Tue, 04 May 2010 21:54:09 +0200 Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Subject: [Qemu-devel] Re: [PATCH v6 5/6] char: unix/tcp: Add a non-blocking write handler List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Amit Shah Cc: Paul Brook , qemu list , Gerd Hoffmann Amit Shah wrote: > Add a non-blocking write handler that can return with -EAGAIN to the > caller and also callback when the socket becomes writable. > > Non-blocking writes are only enabled for sockets that are opened in > non-blocking mode and only for callers that have registered a callback > handler for resuming writes. > > Signed-off-by: Amit Shah I > static void tcp_chr_connect(void *opaque) > { > CharDriverState *chr = opaque; > TCPCharDriver *s = chr->opaque; > + IOHandler *write_cb; > + int flags; > + bool nonblock; > + > + flags = fcntl(s->fd, F_GETFL); > + if (flags == -1) { > + flags = 0; > + } > + nonblock = flags & O_NONBLOCK; > + > + write_cb = NULL; > + chr->nonblock = false; > + if (nonblock && chr->chr_write_unblocked) { > + write_cb = chr->chr_write_unblocked; > + chr->nonblock = true; > + } > > + chr->write_blocked = false; > s->connected = 1; > qemu_set_fd_handler2(s->fd, tcp_chr_read_poll, write_cb is a write-only variable, no?