From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37807) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YceKM-0001Fj-H5 for qemu-devel@nongnu.org; Mon, 30 Mar 2015 14:22:27 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YceKH-0005A4-MS for qemu-devel@nongnu.org; Mon, 30 Mar 2015 14:22:22 -0400 Received: from mx1.redhat.com ([209.132.183.28]:35190) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YceKH-00059m-Fu for qemu-devel@nongnu.org; Mon, 30 Mar 2015 14:22:17 -0400 From: Markus Armbruster References: <1424883128-9841-1-git-send-email-dgilbert@redhat.com> <1424883128-9841-9-git-send-email-dgilbert@redhat.com> <5516C8FE.5090602@redhat.com> <20150329040714.GA9908@voom.fritz.box> <5517BFCB.20304@redhat.com> <20150330165042.GE2474@work-vm> Date: Mon, 30 Mar 2015 20:22:04 +0200 In-Reply-To: <20150330165042.GE2474@work-vm> (David Alan Gilbert's message of "Mon, 30 Mar 2015 17:50:43 +0100") Message-ID: <87pp7qe46r.fsf@blackfin.pond.sub.org> MIME-Version: 1.0 Content-Type: text/plain Subject: Re: [Qemu-devel] [PATCH v5 08/45] Return path: socket_writev_buffer: Block even on non-blocking fd's List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: "Dr. David Alan Gilbert" Cc: aarcange@redhat.com, yamahata@private.email.ne.jp, quintela@redhat.com, qemu-devel@nongnu.org, amit.shah@redhat.com, Paolo Bonzini , yanghy@cn.fujitsu.com, David Gibson "Dr. David Alan Gilbert" writes: > * Paolo Bonzini (pbonzini@redhat.com) wrote: >> >> >> On 29/03/2015 06:07, David Gibson wrote: >> > On Sat, Mar 28, 2015 at 04:30:06PM +0100, Paolo Bonzini wrote: >> >> >> >> >> >> On 25/02/2015 17:51, Dr. David Alan Gilbert (git) wrote: >> >>> + if (err != EAGAIN) { >> >> >> >> if (err != EAGAIN && err != EWOULDBLOCK) >> > >> > I assume that's for the benefit of non-Linux hosts? On Linux >> > EAGAIN == EWOULDBLOCK. >> >> Yes, that's just the standard idiom in QEMU. This is generic code, so >> assumption based on the host platform are not wise. :) > > Done; I didn't know of EWOULDBLOCK - and indeed as far as I can tell > most places we only test for EAGAIN. Bug unless the place in question is effectively #ifdef __GNU_LIBRARY__ or similar. https://www.gnu.org/software/libc/manual/html_node/Error-Codes.html#Error-Codes -- Macro: int EAGAIN Resource temporarily unavailable; the call might work if you try again later. The macro 'EWOULDBLOCK' is another name for 'EAGAIN'; they are always the same in the GNU C Library. This error can happen in a few different situations: * An operation that would block was attempted on an object that has non-blocking mode selected. Trying the same operation again will block until some external condition makes it possible to read, write, or connect (whatever the operation). You can use 'select' to find out when the operation will be possible; *note Waiting for I/O::. *Portability Note:* In many older Unix systems, this condition was indicated by 'EWOULDBLOCK', which was a distinct error code different from 'EAGAIN'. To make your program portable, you should check for both codes and treat them the same. * A temporary resource shortage made an operation impossible. 'fork' can return this error. It indicates that the shortage is expected to pass, so your program can try the call again later and it may succeed. It is probably a good idea to delay for a few seconds before trying it again, to allow time for other processes to release scarce resources. Such shortages are usually fairly serious and affect the whole system, so usually an interactive program should report the error to the user and return to its command loop. -- Macro: int EWOULDBLOCK In the GNU C Library, this is another name for 'EAGAIN' (above). The values are always the same, on every operating system. C libraries in many older Unix systems have 'EWOULDBLOCK' as a separate error code.