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
Junio C Hamano <junkio@cox.net>
Date
Jan 5, 2007, 11:19 UTC
Message-ID
<7vvejlg1pg.fsf@assigned-by-dhcp.cox.net>
In-Reply-To
<1cb8699724ff000fbf0c14ba3e15031e@pinky>
Andy Whitcroft <apw@shadowen.org> writes:
Show 9 quoted lines
>     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).

Previous: Andy WhitcroftNext: Andy Whitcroft
Message 2 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.