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

Re: [PATCH v3] sha1_file: pass empty buffer to index empty file

From
Junio C Hamano <gitster@pobox.com>
Date
May 19, 2015, 18:17 UTC
Message-ID
<xmqqd21w8mal.fsf@gitster.dls.corp.google.com>
In-Reply-To
<xmqqk2w48mjp.fsf@gitster.dls.corp.google.com>
Junio C Hamano <gitster@pobox.com> writes:
Show 13 quoted lines
>> Hmm, I thought we turned off SIGPIPE when writing to filters these days.
>> Looks like we still complain if we get EPIPE, though. I feel like it
>> should be the filter's business whether it wants to consume all of the
>> input or not[1], and we should only be checking its exit status.
>>
>> -Peff
>>
>> [1] As a practical example, consider a file format that has a lot of
>>     cruft at the end. The clean filter would want to read only to the
>>     start of the cruft, and then stop for reasons of efficiency.
>
> Yes.  Let's do these two.  The preparatory patch is larger than the
> real change.
And this is the second one.

While preparing these, I noticed a handful of system calls whose return values are not checked in the codepaths involved. We should clean them up, but I left them out of these two patches, as they are separate issues.

-- >8 --
Subject: [PATCH 2/2] filter_buffer_or_fd(): ignore EPIPE

We are explicitly ignoring SIGPIPE, as we fully expect that the filter program may not read our output fully. Ignore EPIPE that may come from writing to it as well.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
 convert.c | 2 ++
 1 file changed, 2 insertions(+)
diff --git a/convert.c b/convert.c
index 9a5612e..0f20979 100644
--- a/convert.c
+++ b/convert.c
@@ -359,6 +359,8 @@ static int filter_buffer_or_fd(int in, int out, void *data)
 		write_err = (write_in_full(child_process.in, params->src, params->size) < 0);
 	} else {
 		write_err = copy_fd(params->fd, child_process.in);
+		if (write_error == COPY_WRITE_ERROR && errno == EPIPE)
+			write_error = 0; /* we are ignoring it, right? */
 	}
 
 	if (close(child_process.in))
-- 
2.4.1-413-ga38dc94
Previous: Junio C HamanoNext: Junio C Hamano
Message 14 of 23 in “sha1_file: pass empty buffer to index empty file”
  1. sha1_file: pass empty buffer to index empty fileJim Hill, May 14, 2015
  2. Junio C HamanoMay 14, 2015
  3. sha1_file: pass empty buffer to index empty fileJim Hill, May 14, 2015
  4. Junio C HamanoMay 15, 2015
  5. Jim HillMay 15, 2015
  6. Junio C HamanoMay 16, 2015
  7. sha1_file: pass empty buffer to index empty fileJim Hill, May 16, 2015
  8. Junio C HamanoMay 16, 2015
  9. Junio C HamanoMay 17, 2015
  10. Junio C HamanoMay 17, 2015
  11. sha1_file: pass empty buffer to index empty fileJim Hill, May 18, 2015
  12. Jeff KingMay 19, 2015
  13. Junio C HamanoMay 19, 2015
  14. Junio C HamanoMay 19, 2015
  15. Junio C HamanoMay 19, 2015
  16. Junio C HamanoMay 19, 2015
  17. Jeff KingMay 19, 2015
  18. Junio C HamanoMay 20, 2015
  19. Eric SunshineMay 19, 2015
  20. Jeff KingMay 19, 2015
  21. Junio C HamanoMay 20, 2015
  22. Jeff KingMay 20, 2015
  23. Jim HillMay 14, 2015

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.