← Back to team overview

linuxdcpp-team team mailing list archive

[Branch ~dcplusplus-team/dcplusplus/trunk] Rev 2319: Retry on more possible Coral errors

 

------------------------------------------------------------
revno: 2319
committer: eMTee <emtee11@xxxxxxxxx>
branch nick: dcplusplus
timestamp: Fri 2010-12-03 12:29:33 +0100
message:
  Retry on more possible Coral errors
modified:
  changelog.txt
  dcpp/FavoriteManager.cpp
  dcpp/FavoriteManager.h
  dcpp/HttpConnection.cpp
  dcpp/HttpConnection.h
  win32/AboutDlg.cpp
  win32/AboutDlg.h
  win32/MainWindow.cpp
  win32/MainWindow.h


--
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 'changelog.txt'
--- changelog.txt	2010-12-02 15:04:54 +0000
+++ changelog.txt	2010-12-03 11:29:33 +0000
@@ -42,6 +42,7 @@
 * [L#535556] Make sure menus are not too wide (poy)
 * [L#610466] Fix share files instantly when unfinished folder and download target is not on the same drive (emtee)
 * [L#300728] Fix infinitive recursion when sharing a directory with broken name on unix (thanks alexander sashnov)
+* [L#250149] Retry on more possible Coral errors (emtee)
 
 -- 0.770 2010-07-05 --
 * [L#550300] Catch more potential file corruptions (thanks bigmuscle)

=== modified file 'dcpp/FavoriteManager.cpp'
--- dcpp/FavoriteManager.cpp	2010-10-01 14:24:13 +0000
+++ dcpp/FavoriteManager.cpp	2010-12-03 11:29:33 +0000
@@ -830,6 +830,10 @@
 	if(useHttp)
 		listType = TYPE_BZIP2;
 }
+void FavoriteManager::on(Retried, HttpConnection*, const bool Connected) throw() {
+	if (Connected)
+		downloadBuf = Util::emptyString;
+}
 
 void FavoriteManager::on(UserUpdated, const OnlineUser& user) throw() {
 	userUpdated(user);

=== modified file 'dcpp/FavoriteManager.h'
--- dcpp/FavoriteManager.h	2010-10-01 14:24:13 +0000
+++ dcpp/FavoriteManager.h	2010-12-03 11:29:33 +0000
@@ -161,6 +161,7 @@
 	virtual void on(Redirected, HttpConnection*, const string&) throw();
 	virtual void on(TypeNormal, HttpConnection*) throw();
 	virtual void on(TypeBZ2, HttpConnection*) throw();
+	virtual void on(Retried, HttpConnection*, const bool) throw(); 
 
 	bool onHttpFinished(bool fromHttp) throw();
 

=== modified file 'dcpp/HttpConnection.cpp'
--- dcpp/HttpConnection.cpp	2010-02-11 21:44:13 +0000
+++ dcpp/HttpConnection.cpp	2010-12-03 11:29:33 +0000
@@ -102,11 +102,12 @@
 	socket->write("Host: " + sRemoteServer + "\r\n");
 	socket->write("Connection: close\r\n");	// we'll only be doing one request
 	socket->write("Cache-Control: no-cache\r\n\r\n");
-	coralizeState = CST_CONNECTED;
+	if (coralizeState == CST_DEFAULT) coralizeState = CST_CONNECTED;
 }
 
 void HttpConnection::on(BufferedSocketListener::Line, const string& aLine) throw() {
 	if(!ok) {
+		dcdebug("%s\n",aLine.c_str());
 		if(aLine.find("200") == string::npos) {
 			if(aLine.find("301") != string::npos || aLine.find("302") != string::npos){
 				moved302 = true;
@@ -115,13 +116,19 @@
 				socket->removeListener(this);
 				BufferedSocket::putSocket(socket);
 				socket = NULL;
+				if(SETTING(CORAL) && coralizeState != CST_NOCORALIZE) {
+					coralizeState = CST_NOCORALIZE;
+					dcdebug("HTTP error with Coral, retrying : %s\n",currentUrl.c_str());
+					fire(HttpConnectionListener::Retried(), this, coralizeState == CST_CONNECTED);		
+					downloadFile(currentUrl);
+					return;
+				}
 				fire(HttpConnectionListener::Failed(), this, aLine + " (" + currentUrl + ")");
 				coralizeState = CST_DEFAULT;
 				return;
 			}
 		}
 		ok = true;
-		dcdebug("%s\n",aLine.c_str());
 	} else if(moved302 && Util::findSubString(aLine, "Location") != string::npos){
 		dcassert(socket);
 		socket->removeListener(this);
@@ -163,9 +170,10 @@
 	socket->removeListener(this);
 	BufferedSocket::putSocket(socket);
 	socket = NULL;
-	if(BOOLSETTING(CORAL) && coralizeState == CST_DEFAULT) {
+	if(SETTING(CORAL) && coralizeState != CST_NOCORALIZE) {
 		coralizeState = CST_NOCORALIZE;
 		dcdebug("Coralized address failed, retrying : %s\n",currentUrl.c_str());
+		fire(HttpConnectionListener::Retried(), this, coralizeState == CST_CONNECTED);
 		downloadFile(currentUrl);
 		return;
 	}

=== modified file 'dcpp/HttpConnection.h'
--- dcpp/HttpConnection.h	2010-02-11 21:44:13 +0000
+++ dcpp/HttpConnection.h	2010-12-03 11:29:33 +0000
@@ -36,6 +36,7 @@
 	typedef X<3> Redirected;
 	typedef X<4> TypeNormal;
 	typedef X<5> TypeBZ2;
+	typedef X<6> Retried;
 
 	virtual void on(Data, HttpConnection*, const uint8_t*, size_t) throw() =0;
 	virtual void on(Failed, HttpConnection*, const string&) throw() { }
@@ -43,6 +44,7 @@
 	virtual void on(Redirected, HttpConnection*, const string&) throw() { }
 	virtual void on(TypeNormal, HttpConnection*) throw() { }
 	virtual void on(TypeBZ2, HttpConnection*) throw() { }
+	virtual void on(Retried, HttpConnection*, const bool) throw() { }
 };
 
 class HttpConnection : BufferedSocketListener, public Speaker<HttpConnectionListener>

=== modified file 'win32/AboutDlg.cpp'
--- win32/AboutDlg.cpp	2010-12-02 15:04:54 +0000
+++ win32/AboutDlg.cpp	2010-12-03 11:29:33 +0000
@@ -173,3 +173,10 @@
 	callAsync(std::bind(&Label::setText, version, Text::toT(aLine)));
 	conn->removeListener(this);
 }
+
+void AboutDlg::on(HttpConnectionListener::Retried, HttpConnection* /*conn*/, const bool Connected) throw() {
+	if (Connected)
+		downBuf = Util::emptyString;
+}
+
+

=== modified file 'win32/AboutDlg.h'
--- win32/AboutDlg.h	2010-02-11 21:44:13 +0000
+++ win32/AboutDlg.h	2010-12-03 11:29:33 +0000
@@ -45,6 +45,7 @@
 	virtual void on(HttpConnectionListener::Data, HttpConnection* /*conn*/, const uint8_t* buf, size_t len) throw();
 	virtual void on(HttpConnectionListener::Complete, HttpConnection* conn, const string&, bool) throw();
 	virtual void on(HttpConnectionListener::Failed, HttpConnection* conn, const string& aLine) throw();
+	virtual void on(HttpConnectionListener::Retried, HttpConnection* conn, const bool Connected) throw();		
 };
 
 #endif // !defined(DCPLUSPLUS_WIN32_ABOUT_DLG_H)

=== modified file 'win32/MainWindow.cpp'
--- win32/MainWindow.cpp	2010-11-30 18:21:53 +0000
+++ win32/MainWindow.cpp	2010-12-03 11:29:33 +0000
@@ -1387,6 +1387,11 @@
 	versionInfo += string((const char*)buf, len);
 }
 
+ void MainWindow::on(HttpConnectionListener::Retried, HttpConnection* /*conn*/, const bool Connected) throw() {
+ 	if (Connected)
+ 		versionInfo = Util::emptyString;
+ }
+
 void MainWindow::on(PartialList, const HintedUser& aUser, const string& text) throw() {
 	callAsync([this, aUser, text] { DirectoryListingFrame::openWindow(getTabView(), aUser, text, 0); });
 }

=== modified file 'win32/MainWindow.h'
--- win32/MainWindow.h	2010-11-25 18:35:55 +0000
+++ win32/MainWindow.h	2010-12-03 11:29:33 +0000
@@ -209,7 +209,8 @@
 	// HttpConnectionListener
 	virtual void on(HttpConnectionListener::Complete, HttpConnection* conn, string const& /*aLine*/, bool /*fromCoral*/) throw();
 	virtual void on(HttpConnectionListener::Data, HttpConnection* /*conn*/, const uint8_t* buf, size_t len) throw();
-
+	virtual void on(HttpConnectionListener::Retried, HttpConnection* /*conn*/, const bool Connected) throw();		
+		
 	// QueueManagerListener
 	virtual void on(QueueManagerListener::Finished, QueueItem* qi, const string& dir, int64_t speed) throw();
 	virtual void on(PartialList, const HintedUser&, const string& text) throw();