rack-devel archive mirror (unofficial) https://groups.google.com/group/rack-devel
 help / color / mirror / code / Atom feed
From: Charles Oliver Nutter <headius@headius.com>
To: rack-devel@googlegroups.com
Subject: Re: Not cleaning up tempfiles for multipart?
Date: Fri, 5 Mar 2010 08:47:24 -0600	[thread overview]
Message-ID: <f04d2211003050647k4181af21w6e4a4d3b7e1302d4@mail.gmail.com> (raw)
In-Reply-To: <f04d2211003050640m328f5551l225e36ab5a8e2724@mail.gmail.com>

I'm also confused by this code in rewindable_input.rb:

    class Tempfile < ::Tempfile
      def _close
        @tmpfile.close if @tmpfile
        @data[1] = nil if @data
        @tmpfile = nil
      end
    end

the original _close (in 1.8.7) does this, which should be functionally
equivalent:

  def _close    # :nodoc:
    @tmpfile.close if @tmpfile
    @tmpfile = nil
    @data[1] = nil if @data
  end

Is this patching a bug from 1.8.6?

FYI, in JRuby there is no _close, since it's a private impl method and
we have our own tempfile implementation.

- Charlie

On Fri, Mar 5, 2010 at 8:40 AM, Charles Oliver Nutter
<headius@headius.com> wrote:
> I'm investigating some reported tempfle bugs in JRuby, and it seems
> like Rack may not be cleaning up tempfiles it uses.
>
> The creation of the tempfile happens at utils.rb line 486:
>
>      if content_type || filename
>>>    body = Tempfile.new("RackMultipart")
>        body.binmode  if body.respond_to?(:binmode)
>      end
>
> The body is then written to (with the content of the request body),
> rewound, put into the "data" structure, passed to normalize_params
> (which inserts the "data" into the params hash), and that's it. The
> params are then presumably used for the request, and nobody ever
> explicitly cleans up the tempfile.
>
> Am I looking in the wrong place?
>
> If I'm correct, this is a bug. Tempfiles should not be relied upon to
> clean themselves up in response to GC, since you don't know when GC
> will fire...
>
> - Charlie
>

  reply	other threads:[~2010-03-05 14:47 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-03-05 14:40 Charles Oliver Nutter
2010-03-05 14:47 ` Charles Oliver Nutter [this message]
2010-03-05 14:48   ` Charles Oliver Nutter
2010-03-06 10:20   ` Hongli Lai
2010-03-07 14:25     ` Charles Oliver Nutter
2010-03-06  7:55 ` Eric Wong
2010-03-06 10:25   ` Hongli Lai
2010-03-07 14:34     ` Charles Oliver Nutter
2010-03-08  0:22       ` Eric Wong
2010-03-08  1:12         ` Eric Wong
2010-03-17 15:41           ` Charles Oliver Nutter
2010-03-18  9:54             ` Eric Wong
2014-01-06 22:45               ` Wojtek Kruszewski
2014-02-11 21:05                 ` Eric Wong
2014-03-27 21:40                   ` Lenny Marks
2010-03-07 23:53     ` Eric Wong
2010-03-08 11:26       ` Hongli Lai
2010-03-08 11:30         ` Hongli Lai
2010-03-08 14:33           ` Randy Fischer
2010-03-08 14:43           ` Charles Oliver Nutter
2010-03-08 14:49             ` James Tucker
2010-03-17  2:37           ` Eric Wong
2010-03-08 13:22         ` Charles Oliver Nutter
2010-03-08 14:42         ` James Tucker
2010-03-08 17:24           ` Hongli Lai
2010-03-09  7:43             ` Charles Oliver Nutter
2010-03-08 10:05     ` James Tucker
2010-03-07 14:27   ` Charles Oliver Nutter
2010-03-08  0:18     ` Eric Wong
2010-03-08 10:07       ` James Tucker

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://groups.google.com/group/rack-devel

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=f04d2211003050647k4181af21w6e4a4d3b7e1302d4@mail.gmail.com \
    --to=rack-devel@googlegroups.com \
    --subject='Re: Not cleaning up tempfiles for multipart?' \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

Code repositories for project(s) associated with this inbox:

	https://80x24.org/mirrors/rack.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).