From mir at noris.net Wed Aug 25 08:53:17 2010 From: mir at noris.net (Michael Radziej) Date: Wed Aug 25 09:02:36 2010 Subject: [Flow-tools] EINTR in ftio_read() Message-ID: <20100825125317.GQ5453@noris.de> Hi, we use the lib in flow-tools for some other programs. One of these also forks off children and uses a signal handler to keep track of them. Now, when calling ftio_read(), it can happen that the read() gets interrupted by the signal handler, so that read() returns with errno == EINTR. I think that ftio_read() should simply retry the read() in this case as usual, but it doesn't - ftio_read() returns, leaving a message in the log that read() returned EINTR ... (well, and writing this to the log clears errno, so the caller has no way to handle this case). The fix seems easy, but I find it strange that there's nobody else who has encountered this case, with flow-tools being rather old. Google does not find anything related. And my C programming ability is a bit rusty ... So, am I on the wrong path? Kind regards Michael Radziej -- noris network AG - Deutschherrnstra?e 15-19 - D-90429 N?rnberg - Tel +49-911-9352-0 - Fax +49-911-9352-100 http://www.noris.de - The IT-Outsourcing Company Vorstand: Ingo Kraupa (Vorsitzender), Joachim Astel, Hansjochen Klenk - Vorsitzender des Aufsichtsrats: Stefan Schnabel - AG N?rnberg HRB 17689 From i at stingr.net Wed Aug 25 13:00:31 2010 From: i at stingr.net (Paul Komkoff) Date: Wed Aug 25 13:00:35 2010 Subject: [Flow-tools] EINTR in ftio_read() In-Reply-To: <20100825125317.GQ5453@noris.de> References: <20100825125317.GQ5453@noris.de> Message-ID: On Wed, Aug 25, 2010 at 1:53 PM, Michael Radziej wrote: > we use the lib in flow-tools for some other programs. One of these also > forks off children and uses a signal handler to keep track of them. Now, > when calling ftio_read(), it can happen that the read() gets interrupted by > the signal handler, so that read() returns with errno == EINTR. If mmap is possible, then ftio_read doesn't call read. But if it does, you're right, it will fail spectacularly. Feel free to send me a patch against http://gitorious.org/flow-tools/mainline/commits/b0.68.5, for example. -- This message represents the official view of the voices in my head From i at stingr.net Thu Aug 26 10:34:13 2010 From: i at stingr.net (Paul Komkoff) Date: Thu Aug 26 10:34:15 2010 Subject: [Flow-tools] EINTR in ftio_read() In-Reply-To: <20100826093736.GB25010@mega> References: <20100825125317.GQ5453@noris.de> <1282814034.19378.0926424423@intra1.office.noris.de> <20100826093736.GB25010@mega> Message-ID: On Thu, Aug 26, 2010 at 10:37 AM, Florian Forster wrote: > Please find a patch attached. It fixes the implementations of "readn" > and "writen" to handle interruptions correctly and replaces other > occurrences of "read(2)" in "lib/ftio.c". The patch is against the > "b0.68.5" branch (which currently equals "master"). Committed, pushed, 0.68.5.1 tagged, dist-built, pushed to googlecode, now will start fedora rebuilds. -- This message represents the official view of the voices in my head