From 81b9d5b6efbf35b78f90bbd07b7f3ffe0c8ea7af Mon Sep 17 00:00:00 2001 From: Arvid Norberg Date: Sun, 25 Nov 2007 19:09:00 +0000 Subject: [PATCH] made socks5 and socks4 streams ignore errors on close() --- src/socks4_stream.cpp | 23 +++++++++++-------- src/socks5_stream.cpp | 51 ++++++++++++++++++++++++++++--------------- 2 files changed, 48 insertions(+), 26 deletions(-) diff --git a/src/socks4_stream.cpp b/src/socks4_stream.cpp index 3a31b2375..c96dde85b 100644 --- a/src/socks4_stream.cpp +++ b/src/socks4_stream.cpp @@ -43,7 +43,8 @@ namespace libtorrent if (e) { (*h)(e); - close(); + asio::error_code ec; + close(ec); return; } @@ -54,8 +55,8 @@ namespace libtorrent if (i == tcp::resolver::iterator()) { asio::error_code ec = asio::error::operation_not_supported; - (*h)(e); - close(); + (*h)(ec); + close(ec); return; } @@ -68,7 +69,8 @@ namespace libtorrent if (e) { (*h)(e); - close(); + asio::error_code ec; + close(ec); return; } @@ -93,7 +95,8 @@ namespace libtorrent if (e) { (*h)(e); - close(); + asio::error_code ec; + close(ec); return; } @@ -107,7 +110,8 @@ namespace libtorrent if (e) { (*h)(e); - close(); + asio::error_code ec; + close(ec); return; } @@ -119,8 +123,9 @@ namespace libtorrent if (reply_version != 0) { - (*h)(asio::error::operation_not_supported); - close(); + asio::error_code ec = asio::error::operation_not_supported; + (*h)(ec); + close(ec); return; } @@ -140,7 +145,7 @@ namespace libtorrent case 93: ec = asio::error::no_permission; break; } (*h)(ec); - close(); + close(ec); } } diff --git a/src/socks5_stream.cpp b/src/socks5_stream.cpp index a40cd33d0..26d87ab09 100644 --- a/src/socks5_stream.cpp +++ b/src/socks5_stream.cpp @@ -44,7 +44,8 @@ namespace libtorrent if (e || i == tcp::resolver::iterator()) { (*h)(e); - close(); + asio::error_code ec; + close(ec); return; } @@ -57,7 +58,8 @@ namespace libtorrent if (e) { (*h)(e); - close(); + asio::error_code ec; + close(ec); return; } @@ -86,7 +88,8 @@ namespace libtorrent if (e) { (*h)(e); - close(); + asio::error_code ec; + close(ec); return; } @@ -100,7 +103,8 @@ namespace libtorrent if (e) { (*h)(e); - close(); + asio::error_code ec; + close(ec); return; } @@ -113,7 +117,8 @@ namespace libtorrent if (version < 5) { (*h)(asio::error::operation_not_supported); - close(); + asio::error_code ec; + close(ec); return; } @@ -126,7 +131,8 @@ namespace libtorrent if (m_user.empty()) { (*h)(asio::error::operation_not_supported); - close(); + asio::error_code ec; + close(ec); return; } @@ -144,7 +150,8 @@ namespace libtorrent else { (*h)(asio::error::operation_not_supported); - close(); + asio::error_code ec; + close(ec); return; } } @@ -155,7 +162,8 @@ namespace libtorrent if (e) { (*h)(e); - close(); + asio::error_code ec; + close(ec); return; } @@ -170,7 +178,8 @@ namespace libtorrent if (e) { (*h)(e); - close(); + asio::error_code ec; + close(ec); return; } @@ -183,14 +192,16 @@ namespace libtorrent if (version != 1) { (*h)(asio::error::operation_not_supported); - close(); + asio::error_code ec; + close(ec); return; } if (status != 0) { (*h)(asio::error::operation_not_supported); - close(); + asio::error_code ec; + close(ec); return; } @@ -222,7 +233,8 @@ namespace libtorrent if (e) { (*h)(e); - close(); + asio::error_code ec; + close(ec); return; } @@ -236,7 +248,8 @@ namespace libtorrent if (e) { (*h)(e); - close(); + asio::error_code ec; + close(ec); return; } @@ -248,7 +261,8 @@ namespace libtorrent if (version < 5) { (*h)(asio::error::operation_not_supported); - close(); + asio::error_code ec; + close(ec); return; } int response = read_uint8(p); @@ -267,7 +281,8 @@ namespace libtorrent case 8: e = asio::error::address_family_not_supported; break; } (*h)(e); - close(); + asio::error_code ec; + close(ec); return; } p += 1; // reserved @@ -291,7 +306,8 @@ namespace libtorrent else { (*h)(asio::error::operation_not_supported); - close(); + asio::error_code ec; + close(ec); return; } m_buffer.resize(skip_bytes); @@ -305,7 +321,8 @@ namespace libtorrent if (e) { (*h)(e); - close(); + asio::error_code ec; + close(ec); return; }