From 477d5ec238db426ec349ed02ca8f6ebe0f06b4a5 Mon Sep 17 00:00:00 2001 From: Arvid Norberg Date: Fri, 18 Nov 2005 01:12:21 +0000 Subject: [PATCH] merged in differences from release branch --- ChangeLog | 4 +++- docs/manual.html | 2 +- docs/manual.rst | 2 +- examples/make_torrent.cpp | 7 +------ include/libtorrent/socket.hpp | 23 ++++++++++++++++++++--- src/session.cpp | 3 +++ 6 files changed, 29 insertions(+), 12 deletions(-) diff --git a/ChangeLog b/ChangeLog index dad7d6cae..f20a5dd7d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -3,8 +3,10 @@ * added the ability to limit the number of simultaneous half-open TCP connections. Flags in peer_info has been added. -release 0.9.1 +release 0.9.1 + * made the session disable file name checks within the boost.filsystem library + * fixed race condition in the sockets * strings that are invalid utf-8 strings are now decoded with the local codepage on windows * added the ability to build libtorrent both as a shared library diff --git a/docs/manual.html b/docs/manual.html index e4826ce05..953771694 100755 --- a/docs/manual.html +++ b/docs/manual.html @@ -441,7 +441,7 @@ with the following option:

Once the configure script is run successfully, you just type make and libtorrent, the examples and the tests will be built.

When libtorrent is built it may be a good idea to run the tests, you do this -my running make check.

+by running make check.

If you want to build a release version (without debug info, asserts and invariant checks), you have to rerun the configure script and rebuild, like this:

diff --git a/docs/manual.rst b/docs/manual.rst
index fb1c1f8dc..6c7fd7de6 100755
--- a/docs/manual.rst
+++ b/docs/manual.rst
@@ -330,7 +330,7 @@ Once the configure script is run successfully, you just type ``make`` and
 libtorrent, the examples and the tests will be built.
 
 When libtorrent is built it may be a good idea to run the tests, you do this
-my running ``make check``.
+by running ``make check``.
 
 If you want to build a release version (without debug info, asserts and
 invariant checks), you have to rerun the configure script and rebuild, like this::
diff --git a/examples/make_torrent.cpp b/examples/make_torrent.cpp
index de01f4e9b..5cd3595d2 100755
--- a/examples/make_torrent.cpp
+++ b/examples/make_torrent.cpp
@@ -63,10 +63,7 @@ void add_files(
 	else
 	{
 		std::cerr << "adding \"" << l.string() << "\"\n";
-		file fi(f, file::in);
-		fi.seek(0, file::end);
-		libtorrent::size_type size = fi.tell();
-		t.add_file(l, size);
+		t.add_file(l, file_size(f));
 	}
 }
 
@@ -82,8 +79,6 @@ int main(int argc, char* argv[])
 		return 1;
 	}
 
-	path::default_name_check(no_check);
-
 	try
 	{
 		torrent_info t;
diff --git a/include/libtorrent/socket.hpp b/include/libtorrent/socket.hpp
index 386798c11..7b6375971 100755
--- a/include/libtorrent/socket.hpp
+++ b/include/libtorrent/socket.hpp
@@ -41,6 +41,7 @@ POSSIBILITY OF SUCH DAMAGE.
 #include 
 #include 
 #include 
+#include 
 
 #ifdef _MSC_VER
 #pragma warning(pop)
@@ -234,16 +235,19 @@ namespace libtorrent
 
 		void monitor_readability(boost::shared_ptr s)
 		{
+			boost::mutex::scoped_lock l(m_mutex);
 			assert(std::find(m_readable.begin(), m_readable.end(), s) == m_readable.end());
 			m_readable.push_back(s);
 		}
 		void monitor_writability(boost::shared_ptr s)
 		{
+			boost::mutex::scoped_lock l(m_mutex);
 			assert(std::find(m_writable.begin(), m_writable.end(), s) == m_writable.end());
 			m_writable.push_back(s);
 		}
 		void monitor_errors(boost::shared_ptr s)
 		{
+			boost::mutex::scoped_lock l(m_mutex);
 			assert(std::find(m_error.begin(), m_error.end(), s) == m_error.end());
 			m_error.push_back(s);
 		}
@@ -251,19 +255,27 @@ namespace libtorrent
 		void remove(boost::shared_ptr s);
 
 		void remove_writable(boost::shared_ptr s)
-		{ m_writable.erase(std::find(m_writable.begin(), m_writable.end(), s)); }
+		{
+			boost::mutex::scoped_lock l(m_mutex);
+			m_writable.erase(std::find(m_writable.begin(), m_writable.end(), s));
+		}
 
 		void remove_readable(boost::shared_ptr s)
-		{ m_readable.erase(std::find(m_readable.begin(), m_readable.end(), s)); }
+		{
+			boost::mutex::scoped_lock l(m_mutex);
+			m_readable.erase(std::find(m_readable.begin(), m_readable.end(), s));
+		}
 
 		bool is_writability_monitored(boost::shared_ptr s)
 		{
+			boost::mutex::scoped_lock l(m_mutex);
 			return std::find(m_writable.begin(), m_writable.end(), s)
 				!= m_writable.end();
 		}
 
 		bool is_readability_monitored(boost::shared_ptr s)
 		{
+			boost::mutex::scoped_lock l(m_mutex);
 			return std::find(m_readable.begin(), m_readable.end(), s)
 				!= m_readable.end();
 		}
@@ -273,10 +285,15 @@ namespace libtorrent
 			, std::vector >& writable
 			, std::vector >& error);
 
-		int count_read_monitors() const { return (int)m_readable.size(); }
+		int count_read_monitors() const
+		{
+			boost::mutex::scoped_lock l(m_mutex);
+			return (int)m_readable.size();
+		}
 
 	private:
 
+		mutable boost::mutex m_mutex;
 		std::vector > m_readable;
 		std::vector > m_writable;
 		std::vector > m_error;
diff --git a/src/session.cpp b/src/session.cpp
index 126a99679..583700acf 100755
--- a/src/session.cpp
+++ b/src/session.cpp
@@ -1142,6 +1142,9 @@ namespace libtorrent
 		, m_thread(boost::ref(m_impl))
 		, m_checker_thread(boost::ref(m_checker_impl))
 	{
+		// turn off the filename checking in boost.filesystem
+		using namespace boost::filesystem;
+		path::default_name_check(native);
 		assert(listen_port_range.first > 0);
 		assert(listen_port_range.first < listen_port_range.second);
 #ifndef NDEBUG