Skip to content

Instantly share code, notes, and snippets.

@djmitche
Created February 5, 2010 18:52
Show Gist options
  • Select an option

  • Save djmitche/296083 to your computer and use it in GitHub Desktop.

Select an option

Save djmitche/296083 to your computer and use it in GitHub Desktop.
close the output file if not assembling
restore-src/restore.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
I tested this both with a straight amrestore and with a compression pipeline.
Both worked without leaking FD's
Index: restore-src/restore.c
===================================================================
--- restore-src/restore.c (revision 2508)
+++ restore-src/restore.c (working copy)
@@ -1206,8 +1206,12 @@
oldout = alloc(SIZEOF(open_output_t));
oldout->file = alloc(SIZEOF(dumpfile_t));
memcpy(oldout->file, source->header, SIZEOF(dumpfile_t));
- if(flags->inline_assemble) oldout->outfd = pipes[0].pipe[1];
- else oldout->outfd = -1;
+ if(flags->inline_assemble) {
+ oldout->outfd = pipes[0].pipe[1];
+ } else {
+ oldout->outfd = -1;
+ aclose(pipes[0].pipe[1]);
+ }
oldout->comp_enc_pid = -1;
oldout->lastpartnum = source->header->partnum;
oldout->next = open_outputs;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment