mirror of
https://github.com/twisterarmy/twister-core.git
synced 2025-01-11 15:27:57 +00:00
rework initialization order a little, try to start torrents after dht comes up
This commit is contained in:
parent
e80acded1f
commit
019da72568
@ -161,21 +161,31 @@ void ThreadWaitExtIP()
|
|||||||
settings.anonymous_mode = false; // (false => send peer_id, avoid connecting to itself)
|
settings.anonymous_mode = false; // (false => send peer_id, avoid connecting to itself)
|
||||||
ses->set_settings(settings);
|
ses->set_settings(settings);
|
||||||
|
|
||||||
|
printf("libtorrent + dht started\n");
|
||||||
|
|
||||||
boost::filesystem::path userDataPath = GetDataDir() / "user_data";
|
// wait up to 10 seconds for dht nodes to be set
|
||||||
loadUserData(userDataPath.string(), m_users);
|
for( int i = 0; i < 10; i++ ) {
|
||||||
printf("loaded user_data for %zd users\n", m_users.size());
|
MilliSleep(1000);
|
||||||
|
session_status ss = ses->status();
|
||||||
// now restart the user torrents (all m_following)
|
if( ss.dht_nodes )
|
||||||
std::map<std::string,UserData>::const_iterator i;
|
break;
|
||||||
for (i = m_users.begin(); i != m_users.end(); ++i) {
|
|
||||||
UserData const &data = i->second;
|
|
||||||
BOOST_FOREACH(string username, data.m_following) {
|
|
||||||
startTorrentUser(username);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
printf("libtorrent + dht started\n");
|
{
|
||||||
|
LOCK(cs_twister);
|
||||||
|
boost::filesystem::path userDataPath = GetDataDir() / "user_data";
|
||||||
|
loadUserData(userDataPath.string(), m_users);
|
||||||
|
printf("loaded user_data for %zd users\n", m_users.size());
|
||||||
|
|
||||||
|
// now restart the user torrents (all m_following)
|
||||||
|
std::map<std::string,UserData>::const_iterator i;
|
||||||
|
for (i = m_users.begin(); i != m_users.end(); ++i) {
|
||||||
|
UserData const &data = i->second;
|
||||||
|
BOOST_FOREACH(string username, data.m_following) {
|
||||||
|
startTorrentUser(username);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ThreadMaintainDHTNodes()
|
void ThreadMaintainDHTNodes()
|
||||||
@ -183,7 +193,7 @@ void ThreadMaintainDHTNodes()
|
|||||||
RenameThread("maintain-dht-nodes");
|
RenameThread("maintain-dht-nodes");
|
||||||
|
|
||||||
while(1) {
|
while(1) {
|
||||||
MilliSleep(15000);
|
MilliSleep(5000);
|
||||||
|
|
||||||
bool nodesAdded = false;
|
bool nodesAdded = false;
|
||||||
if( ses ) {
|
if( ses ) {
|
||||||
|
Loading…
Reference in New Issue
Block a user