← Back to team overview

linuxdcpp-team team mailing list archive

[Branch ~dcplusplus-team/dcplusplus/trunk] Rev 2885: disable mapped file reads on Windows (see comment in FileReader::readMapped)

 

------------------------------------------------------------
revno: 2885
committer: poy <poy@xxxxxxxxxx>
branch nick: trunk
timestamp: Wed 2012-03-21 18:39:02 +0100
message:
  disable mapped file reads on Windows (see comment in FileReader::readMapped)
modified:
  dcpp/FileReader.cpp
  dcpp/QueueManager.cpp


--
lp:dcplusplus
https://code.launchpad.net/~dcplusplus-team/dcplusplus/trunk

Your team Dcplusplus-team is subscribed to branch lp:dcplusplus.
To unsubscribe from this branch go to https://code.launchpad.net/~dcplusplus-team/dcplusplus/trunk/+edit-subscription
=== modified file 'dcpp/FileReader.cpp'
--- dcpp/FileReader.cpp	2012-03-21 06:04:32 +0000
+++ dcpp/FileReader.cpp	2012-03-21 17:39:02 +0000
@@ -196,6 +196,18 @@
 }
 
 size_t FileReader::readMapped(const string& file, const DataCallback& callback) {
+	/** @todo mapped reads can fail on Windows by throwing an exception that may only be caught by
+	SEH. MinGW doesn't have that, thus making this method of reading prone to unrecoverable
+	failures. disabling this for now should be fine as DC++ always tries overlapped reads first
+	(at the moment this file reader is only used in places where overlapped reads make the most
+	sense).
+	more info:
+	<http://msdn.microsoft.com/en-us/library/aa366801(VS.85).aspx>
+	<http://stackoverflow.com/q/7244645> */
+#if 1
+	return READ_FAILED;
+#else
+
 	auto tfile = Text::toT(file);
 
 	auto tmp = ::CreateFile(tfile.c_str(), GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING,
@@ -246,6 +258,7 @@
 	}
 
 	return total.QuadPart;
+#endif
 }
 
 #else

=== modified file 'dcpp/QueueManager.cpp'
--- dcpp/QueueManager.cpp	2012-03-03 19:33:45 +0000
+++ dcpp/QueueManager.cpp	2012-03-21 17:39:02 +0000
@@ -408,7 +408,7 @@
 		TigerTree ttFile(tt.getBlockSize());
 
 		try {
-			FileReader().read(tempTarget, [&](const void* x, size_t n) {
+			FileReader(true).read(tempTarget, [&](const void* x, size_t n) {
 				return ttFile.update(x, n), true;
 			});
 		} catch(const FileException & e) {
@@ -1627,7 +1627,7 @@
 
 uint32_t QueueManager::calcCrc32(const string& file) {
 	CRC32Filter crc32;
-	FileReader().read(file, [&](const void* x, size_t n) {
+	FileReader(true).read(file, [&](const void* x, size_t n) {
 		return crc32(x, n), true;
 	});
 	return crc32.getValue();