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

Re: [PATCH 0/5] Retry if fdopen() fails due to ENOMEM

From
Michael Haggerty <mhagger@alum.mit.edu>
Date
Mar 10, 2015, 11:44 UTC
Message-ID
<54FED916.6020607@alum.mit.edu>
In-Reply-To
<54F9365E.2000705@web.de>
On 03/06/2015 06:08 AM, Torsten Bögershausen wrote:
Show 20 quoted lines
> On 03/05/2015 05:07 PM, Michael Haggerty wrote:
>> One likely reason for fdopen() to fail is the lack of memory for
>> allocating a FILE structure. When that happens, try freeing some
>> memory and calling fdopen() again in the hope that it will work the
>> second time.
>>
>> This change was suggested by Jonathan Nieder [1]
>>
>> In the first patch it is unsatisfying that try_to_free_routine() is
>> called with a magic number (1000) rather than sizeof(FILE). But the C
>> standard doesn't guarantee that FILE is a complete type, so I can't
>> think of a better approach. Suggestions, anybody?
> 
> it's not the sizeof(FILE) which is critical, it is the size of the buffer
> associated with a FILE
> 
> http://pubs.opengroup.org/onlinepubs/009695399/basedefs/stdio.h.html
> 
> BUFSIZ may be  your friend, and if it is not defined, 4096 may be a
> useful default.

Good point. If this patch series is not dropped as being useless, I will make this change.

Michael
-- 
Michael Haggerty
mhagger@alum.mit.edu
Previous: Torsten BögershausenNext: Junio C Hamano
Message 12 of 13 in “Retry if fdopen() fails due to ENOMEM”
  1. 0/5 Retry if fdopen() fails due to ENOMEMMichael Haggerty, Mar 5, 2015
  2. 1/5 xfdopen(): if first attempt fails, free memory and try againMichael Haggerty, Mar 5, 2015
  3. Stefan BellerMar 5, 2015
  4. Junio C HamanoMar 5, 2015
  5. 2/5 fdopen_lock_file(): use fdopen_with_retry()Michael Haggerty, Mar 5, 2015
  6. 3/5 copy_to_log(): use fdopen_with_retry()Michael Haggerty, Mar 5, 2015
  7. 4/5 update_info_file(): use fdopen_with_retry()Michael Haggerty, Mar 5, 2015
  8. 5/5 buffer_fdinit(): use fdopen_with_retry()Michael Haggerty, Mar 5, 2015
  9. Junio C HamanoMar 5, 2015
  10. Michael HaggertyMar 10, 2015
  11. Torsten BögershausenMar 6, 2015
  12. Michael HaggertyMar 10, 2015
  13. Junio C HamanoMar 17, 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.