git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] use xread where we are not checking for EAGAIN/EINTR

From
Andy Whitcroft <apw@shadowen.org>
Date
Jan 5, 2007, 12:20 UTC
Message-ID
<459E4270.9090307@shadowen.org>
In-Reply-To
<7vvejlg1pg.fsf@assigned-by-dhcp.cox.net>
Junio C Hamano wrote:
Show 26 quoted lines
> Andy Whitcroft <apw@shadowen.org> writes:
> 
>>     We have an xread() wrapper to help us with those nasty
>>     interrupt returns and yet we fail to use it consistently.
>>     This patch updates those plain read()'s which do not
>>     have any handling for errors, or which treat those errors
>>     as user visible fatal errors.
>>
>>     This feels right to me, but perhaps there is some good
>>     reason that things are done this way ... if so could
>>     someone elighten me.
> 
> Thanks.
> 
> I do not think any of the changes you did introduced new bugs,
> but I think some of them are still wrong.  xread() protects us
> from EINTR happening before any byte is read, but it can still
> give a short read.  Many callers have a loop like this:
> 
> 	do {
>         	size = xread(...);
>                 yet_to_go -= size;
> 	} while (yet_to_go);
> 
> but some are not (e.g. add_excludes_from_file_1() in dir.c
> expects xread() does not return before reading full buffer).

Yes, that is true. I was going to fix that in the next step with the writes. But yes thats likely to involve them becoming 'read_in_full' style thing and in fact churn us more.

Ignore this one and I'll look to do it 'right'.
-apw
Previous: Junio C HamanoNext: Andy Whitcroft
Message 3 of 10 in “use xread where we are not checking for EAGAIN/EINTR”
  1. use xread where we are not checking for EAGAIN/EINTRAndy Whitcroft, Jan 5, 2007
  2. Junio C HamanoJan 5, 2007
  3. Andy WhitcroftJan 5, 2007
  4. Andy WhitcroftJan 8, 2007
  5. 1/4 short i/o: clean up the naming for the write_{in,or}_xxx familyAndy Whitcroft, Jan 8, 2007
  6. 2/4 short i/o: fix calls to read to use xread or read_in_fullAndy Whitcroft, Jan 8, 2007
  7. 3/4 short i/o: fix calls to write to use xwrite or write_in_fullAndy Whitcroft, Jan 8, 2007
  8. 4/4 short i/o: fix config updates to use write_in_fullAndy Whitcroft, Jan 8, 2007
  9. Junio C HamanoJan 8, 2007
  10. Avoid errors and warnings when attempting to do I/O on zero bytesEric Wong, Jan 11, 2007

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.