diff --git a/mercurial/httppeer.py b/mercurial/httppeer.py
index e9165c18f8dfd8a065f6c847c20b52befe3b5957_bWVyY3VyaWFsL2h0dHBwZWVyLnB5..cde6904f199216d9c077e3db04bea4359fd4488c_bWVyY3VyaWFsL2h0dHBwZWVyLnB5 100644
--- a/mercurial/httppeer.py
+++ b/mercurial/httppeer.py
@@ -214,6 +214,7 @@
 
     def _calltwowaystream(self, cmd, fp, **args):
         fh = None
+        fp_ = None
         filename = None
         try:
             # dump bundle to disk
@@ -225,5 +226,5 @@
                 d = fp.read(4096)
             fh.close()
             # start http push
-            fp = httpconnection.httpsendfile(self.ui, filename, "rb")
+            fp_ = httpconnection.httpsendfile(self.ui, filename, "rb")
             headers = {'Content-Type': 'application/mercurial-0.1'}
@@ -229,3 +230,3 @@
             headers = {'Content-Type': 'application/mercurial-0.1'}
-            return self._callstream(cmd, data=fp, headers=headers, **args)
+            return self._callstream(cmd, data=fp_, headers=headers, **args)
         finally:
@@ -231,4 +232,6 @@
         finally:
+            if fp_ is not None:
+                fp_.close()
             if fh is not None:
                 fh.close()
                 os.unlink(filename)