linuxdcpp-team team mailing list archive
-
linuxdcpp-team team
-
Mailing list archive
-
Message #06763
[Branch ~dcplusplus-team/dcplusplus/trunk] Rev 3258: http
------------------------------------------------------------
revno: 3258
committer: poy <poy@xxxxxxxxxx>
branch nick: trunk
timestamp: Sun 2013-04-14 22:28:35 +0200
message:
http
modified:
dcpp/HttpManager.cpp
win32/AboutDlg.cpp
win32/MainWindow.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/HttpManager.cpp'
--- dcpp/HttpManager.cpp 2013-04-13 15:08:45 +0000
+++ dcpp/HttpManager.cpp 2013-04-14 20:28:35 +0000
@@ -103,10 +103,12 @@
}
void HttpManager::on(HttpConnectionListener::Data, HttpConnection* c, const uint8_t* data, size_t len) noexcept {
+ OutputStream* stream;
{
Lock l(cs);
- findConn(c)->stream->write(data, len);
+ stream = findConn(c)->stream;
}
+ stream->write(data, len);
fire(HttpManagerListener::Updated(), c);
}
@@ -121,6 +123,7 @@
Lock l(cs);
stream = findConn(c)->stream;
}
+ stream->flush();
fire(HttpManagerListener::Complete(), c, stream);
removeLater(c);
}
=== modified file 'win32/AboutDlg.cpp'
--- win32/AboutDlg.cpp 2013-04-13 15:08:45 +0000
+++ win32/AboutDlg.cpp 2013-04-14 20:28:35 +0000
@@ -187,17 +187,19 @@
}
version->setText(str.empty() ? Text::toT(result) : str);
-
- c = nullptr;
}
void AboutDlg::on(HttpManagerListener::Failed, HttpConnection* c, const string& str) noexcept {
if(c != this->c) { return; }
+ c = nullptr;
+
callAsync([str, this] { completeDownload(false, str); });
}
void AboutDlg::on(HttpManagerListener::Complete, HttpConnection* c, OutputStream* stream) noexcept {
if(c != this->c) { return; }
+ c = nullptr;
+
auto str = static_cast<StringOutputStream*>(stream)->getString();
callAsync([str, this] { completeDownload(true, str); });
}
=== modified file 'win32/MainWindow.cpp'
--- win32/MainWindow.cpp 2013-04-13 15:08:45 +0000
+++ win32/MainWindow.cpp 2013-04-14 20:28:35 +0000
@@ -1349,8 +1349,6 @@
}
void MainWindow::completeVersionUpdate(bool success, const string& result) {
- if(!conns[CONN_VERSION]) { return; }
-
if(success) { try {
SimpleXML xml;
xml.fromXML(result);
@@ -1455,8 +1453,6 @@
xml.stepOut();
} catch (const Exception&) { } }
- conns[CONN_VERSION] = nullptr;
-
// check after the version.xml download in case it contains updated GeoIP links.
if(SETTING(GET_USER_COUNTRY)) {
checkGeoUpdate();
@@ -1499,10 +1495,6 @@
}
void MainWindow::completeGeoUpdate(bool v6, bool success, const string& result) {
- auto& conn = conns[v6 ? CONN_GEO_V6 : CONN_GEO_V4];
- if(!conn) { return; }
- ScopedFunctor([&conn] { conn = nullptr; });
-
if(success && !result.empty()) {
try {
File(GeoManager::getDbPath(v6) + ".gz", File::WRITE, File::CREATE | File::TRUNCATE).write(result);
@@ -1748,22 +1740,35 @@
void MainWindow::on(HttpManagerListener::Failed, HttpConnection* c, const string&) noexcept {
if(c == conns[CONN_VERSION]) {
+ conns[CONN_VERSION] = nullptr;
callAsync([this] { completeVersionUpdate(false, Util::emptyString); });
+
} else if(c == conns[CONN_GEO_V6]) {
+ conns[CONN_GEO_V6] = nullptr;
callAsync([this] { completeGeoUpdate(true, false, Util::emptyString); });
+
} else if(c == conns[CONN_GEO_V4]) {
+ conns[CONN_GEO_V4] = nullptr;
callAsync([this] { completeGeoUpdate(false, false, Util::emptyString); });
}
}
void MainWindow::on(HttpManagerListener::Complete, HttpConnection* c, OutputStream* stream) noexcept {
if(c == conns[CONN_VERSION]) {
+ conns[CONN_VERSION] = nullptr;
+
auto str = static_cast<StringOutputStream*>(stream)->getString();
callAsync([str, this] { completeVersionUpdate(true, str); });
+
} else if(c == conns[CONN_GEO_V6]) {
+ conns[CONN_GEO_V6] = nullptr;
+
auto str = static_cast<StringOutputStream*>(stream)->getString();
callAsync([str, this] { completeGeoUpdate(true, true, str); });
+
} else if(c == conns[CONN_GEO_V4]) {
+ conns[CONN_GEO_V4] = nulllptr;
+
auto str = static_cast<StringOutputStream*>(stream)->getString();
callAsync([str, this] { completeGeoUpdate(false, true, str); });
}