From 79d83988cb08ff646fcf7950c74e366ae6ebc290 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Tue, 8 Nov 2011 10:08:38 +0000 Subject: bigfile: explicitly close HTTPReader socket No need to unnecessarily trigger GC nor hit EMFILE/ENFILE on VMs that rarely GC IO objects... --- lib/mogilefs/bigfile.rb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/mogilefs/bigfile.rb b/lib/mogilefs/bigfile.rb index 8d5c75f..872cc5c 100644 --- a/lib/mogilefs/bigfile.rb +++ b/lib/mogilefs/bigfile.rb @@ -45,7 +45,11 @@ module MogileFS::Bigfile sock = MogileFS::HTTPReader.first(paths, t) end - w = MogileFS::X.copy_stream(sock, wr_io) + begin + w = MogileFS::X.copy_stream(sock, wr_io) + ensure + sock.close + end wr_io.respond_to?(:md5_check!) and wr_io.md5_check!(part[:md5]) total += w -- cgit v1.2.3-24-ge0c7