mirror of https://github.com/aria2/aria2
2008-07-12 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
Moved the calls of std::ios::exceptions() inside of try-catch block because if an error occurred in constructor of std::fstream, then exception is thrown immediately when std::ios::exceptions() is called which results unhandled exception and aria2c aborts. * src/DefaultBtProgressInfoFile.ccpull/1/head
parent
cefbf6407e
commit
c3fbc48d4c
|
@ -1,3 +1,11 @@
|
||||||
|
2008-07-12 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
|
||||||
|
|
||||||
|
Moved the calls of std::ios::exceptions() inside of try-catch block
|
||||||
|
because if an error occurred in constructor of std::fstream, then
|
||||||
|
exception is thrown immediately when std::ios::exceptions() is called
|
||||||
|
which results unhandled exception and aria2c aborts.
|
||||||
|
* src/DefaultBtProgressInfoFile.cc
|
||||||
|
|
||||||
2008-07-12 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
|
2008-07-12 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
|
||||||
|
|
||||||
Added the test for the previous change in DefaultBtContext.cc
|
Added the test for the previous change in DefaultBtContext.cc
|
||||||
|
|
|
@ -91,8 +91,8 @@ void DefaultBtProgressInfoFile::save() {
|
||||||
_logger->info(MSG_SAVING_SEGMENT_FILE, _filename.c_str());
|
_logger->info(MSG_SAVING_SEGMENT_FILE, _filename.c_str());
|
||||||
std::string filenameTemp = _filename+"__temp";
|
std::string filenameTemp = _filename+"__temp";
|
||||||
std::ofstream o(filenameTemp.c_str(), std::ios::out|std::ios::binary);
|
std::ofstream o(filenameTemp.c_str(), std::ios::out|std::ios::binary);
|
||||||
o.exceptions(std::ios::failbit);
|
|
||||||
try {
|
try {
|
||||||
|
o.exceptions(std::ios::failbit);
|
||||||
bool torrentDownload = isTorrentDownload();
|
bool torrentDownload = isTorrentDownload();
|
||||||
// file version: 16 bits
|
// file version: 16 bits
|
||||||
// value: '0'
|
// value: '0'
|
||||||
|
@ -175,10 +175,10 @@ void DefaultBtProgressInfoFile::load()
|
||||||
{
|
{
|
||||||
_logger->info(MSG_LOADING_SEGMENT_FILE, _filename.c_str());
|
_logger->info(MSG_LOADING_SEGMENT_FILE, _filename.c_str());
|
||||||
std::ifstream in(_filename.c_str(), std::ios::in|std::ios::binary);
|
std::ifstream in(_filename.c_str(), std::ios::in|std::ios::binary);
|
||||||
in.exceptions(std::ios::failbit);
|
|
||||||
unsigned char* savedInfoHash = 0;
|
unsigned char* savedInfoHash = 0;
|
||||||
unsigned char* savedBitfield = 0;
|
unsigned char* savedBitfield = 0;
|
||||||
try {
|
try {
|
||||||
|
in.exceptions(std::ios::failbit);
|
||||||
unsigned char version[2];
|
unsigned char version[2];
|
||||||
in.read((char*)version, sizeof(version));
|
in.read((char*)version, sizeof(version));
|
||||||
if(DefaultBtProgressInfoFile::V0000 != Util::toHex(version, sizeof(version))) {
|
if(DefaultBtProgressInfoFile::V0000 != Util::toHex(version, sizeof(version))) {
|
||||||
|
|
Loading…
Reference in New Issue