From: Leandro Lucarella Date: Fri, 24 Oct 2003 02:31:46 +0000 (+0000) Subject: Se mueve el mutex a la clase que tiene el recurso a proteger. X-Git-Tag: svn_import~370 X-Git-Url: https://git.llucax.com/z.facultad/75.42/plaqui.git/commitdiff_plain/292425c2f65528535f137b437e629c5785c870d0?ds=sidebyside Se mueve el mutex a la clase que tiene el recurso a proteger. --- diff --git a/Server/include/plaqui/server/runnable.h b/Server/include/plaqui/server/runnable.h index cc3bb0e..7896090 100644 --- a/Server/include/plaqui/server/runnable.h +++ b/Server/include/plaqui/server/runnable.h @@ -64,12 +64,6 @@ namespace Server { */ bool stop; - /** - * Exclusión mutua. - * Recurso usado para recibir la exclusividad sobre un recurso. - */ - Glib::Mutex mutex; - // Métodos. private: diff --git a/Server/include/plaqui/server/tcpserver.h b/Server/include/plaqui/server/tcpserver.h index 0290629..393f4cc 100644 --- a/Server/include/plaqui/server/tcpserver.h +++ b/Server/include/plaqui/server/tcpserver.h @@ -60,6 +60,9 @@ namespace Server { /// Socket para escuchar conexiones. sockinetbuf socket; + /// Mutex para las conexiones. + Glib::Mutex connections_mutex; + /// Conexiones de control. ConnectionList connections; diff --git a/Server/src/tcpserver.cpp b/Server/src/tcpserver.cpp index a9ce030..d2bb7fd 100644 --- a/Server/src/tcpserver.cpp +++ b/Server/src/tcpserver.cpp @@ -62,7 +62,9 @@ void PlaQui::Server::TCPServer::on_connection_finished( std::cerr << __FILE__ << ": on_connection_finished(connection = " << connection << ")" << std::endl; #endif // DEBUG - mutex.lock(); + connections_mutex.lock(); + // FIXME pruebo el mutex. + sleep(5); connections.remove(connection); #ifdef DEBUG std::cerr << __FILE__ << ": lista de conexiones" << std::endl; @@ -71,7 +73,7 @@ void PlaQui::Server::TCPServer::on_connection_finished( std::cerr << "\t " << *i << std::endl; } #endif // DEBUG - mutex.unlock(); + connections_mutex.unlock(); } /// \todo TODO: ver tema de timeout o como salir de un accept(). @@ -87,7 +89,9 @@ void PlaQui::Server::TCPServer::real_run(void) { std::cerr << __FILE__ << ": real_run(): connection = " << connection << std::endl; #endif // DEBUG - mutex.lock(); + connections_mutex.lock(); + // FIXME pruebo el mutex. + sleep(5); connections.push_back(connection); #ifdef DEBUG std::cerr << __FILE__ << ": real_run(): lista de conexiones" << std::endl; @@ -96,7 +100,7 @@ void PlaQui::Server::TCPServer::real_run(void) { std::cerr << "\t " << *i << std::endl; } #endif // DEBUG - mutex.unlock(); + connections_mutex.unlock(); // Conecto la señal para cuando termina una conexión, borrarla. connection->signal_finished().connect( SigC::bind(