mirror of
https://github.com/clangen/musikcube.git
synced 2025-01-01 17:58:29 +00:00
Fixed bug in musik::core::Crypt, forgot to seed boost::random.
Fixed problem with musikServer when joining Connection threads.
This commit is contained in:
parent
49c0d5d271
commit
21e97a719b
@ -51,7 +51,8 @@ std::string Crypt::GenerateSalt(){
|
||||
|
||||
typedef boost::mt19937 RandomGenerator;
|
||||
RandomGenerator randomGenerator;
|
||||
|
||||
|
||||
randomGenerator.seed(static_cast<unsigned int>(std::time(0)));
|
||||
|
||||
boost::uniform_int<> randDistribution(0,(int)characters.size()-1);
|
||||
boost::variate_generator<RandomGenerator&, boost::uniform_int<> > rand(randomGenerator, randDistribution);
|
||||
|
@ -56,11 +56,16 @@ Server::Server(unsigned int port,unsigned int httpPort)
|
||||
}
|
||||
|
||||
Server::~Server(void){
|
||||
this->connections.clear();
|
||||
this->nextConnection.reset();
|
||||
|
||||
this->Exit();
|
||||
|
||||
{
|
||||
boost::mutex::scoped_lock lock(this->serverMutex);
|
||||
this->connectedUsers.clear();
|
||||
this->connections.clear();
|
||||
}
|
||||
|
||||
this->nextConnection.reset();
|
||||
|
||||
this->threads.join_all();
|
||||
}
|
||||
|
||||
@ -136,17 +141,22 @@ void Server::SetNextConnection(){
|
||||
|
||||
void Server::AcceptConnection(const boost::system::error_code& error){
|
||||
if(!error){
|
||||
this->CleanupConnections();
|
||||
|
||||
// Start the connection
|
||||
this->nextConnection->Startup();
|
||||
|
||||
this->connections.push_back(this->nextConnection);
|
||||
this->SetNextConnection();
|
||||
{
|
||||
boost::mutex::scoped_lock lock(this->serverMutex);
|
||||
|
||||
this->connections.push_back(this->nextConnection);
|
||||
this->SetNextConnection();
|
||||
}
|
||||
|
||||
this->CleanupConnections();
|
||||
}
|
||||
}
|
||||
|
||||
void Server::CleanupConnections(){
|
||||
boost::mutex::scoped_lock lock(this->serverMutex);
|
||||
for(server::ConnectionVector::iterator connection=this->connections.begin();connection!=this->connections.end();){
|
||||
if( (*connection)->Exited() ){
|
||||
connection = this->connections.erase(connection);
|
||||
|
@ -268,7 +268,7 @@ void Connection::WriteThread(){
|
||||
// Wait for outgoingQueries
|
||||
{
|
||||
boost::mutex::scoped_lock lock(this->libraryMutex);
|
||||
if(this->outgoingQueries.empty()){
|
||||
if(this->outgoingQueries.empty() && !this->exit){
|
||||
this->waitCondition.wait(lock);
|
||||
}
|
||||
|
||||
@ -337,4 +337,5 @@ void Connection::Exit(){
|
||||
this->exit = true;
|
||||
}
|
||||
this->waitCondition.notify_all();
|
||||
this->authCondition.notify_all();
|
||||
}
|
||||
|
@ -76,7 +76,7 @@ void SyncPathModel::UpdateSyncPaths(){
|
||||
}
|
||||
|
||||
this->SetRowCount(0);
|
||||
this->SetRowCount(this->paths.size());
|
||||
this->SetRowCount((int)this->paths.size());
|
||||
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user