Make the http connection close detection work properly with bufferevents and fix a potential memory leak associated with it svn:r963