X-Git-Url: https://git.llucax.com/z.facultad/75.42/plaqui.git/blobdiff_plain/60d025bd1152960ac9131128c7cea2b7af8a406e..f1f2d6a48b96c759d197d1227e157665d0d7bbcc:/Server/src/tcpserver.cpp diff --git a/Server/src/tcpserver.cpp b/Server/src/tcpserver.cpp index d2bb7fd..a7b3dc7 100644 --- a/Server/src/tcpserver.cpp +++ b/Server/src/tcpserver.cpp @@ -27,11 +27,13 @@ #include "plaqui/server/tcpserver.h" #include +// FIXME - para probar mutex +#include #ifdef DEBUG # include #endif // DEBUG -const unsigned PlaQui::Server::TCPServer::MAX_PENDING_CONNECTIONS = 5; +const unsigned PlaQui::Server::TCPServer::MAX_PENDING_CONNECTIONS = 10; PlaQui::Server::TCPServer::~TCPServer(void) { #ifdef DEBUG @@ -62,9 +64,8 @@ void PlaQui::Server::TCPServer::on_connection_finished( std::cerr << __FILE__ << ": on_connection_finished(connection = " << connection << ")" << std::endl; #endif // DEBUG - connections_mutex.lock(); - // FIXME pruebo el mutex. - sleep(5); + Glib::Mutex::Lock lock(connections_mutex); + // XXX connections_mutex.lock(); connections.remove(connection); #ifdef DEBUG std::cerr << __FILE__ << ": lista de conexiones" << std::endl; @@ -73,7 +74,7 @@ void PlaQui::Server::TCPServer::on_connection_finished( std::cerr << "\t " << *i << std::endl; } #endif // DEBUG - connections_mutex.unlock(); + // XXX connections_mutex.unlock(); } /// \todo TODO: ver tema de timeout o como salir de un accept(). @@ -89,9 +90,7 @@ void PlaQui::Server::TCPServer::real_run(void) { std::cerr << __FILE__ << ": real_run(): connection = " << connection << std::endl; #endif // DEBUG - connections_mutex.lock(); - // FIXME pruebo el mutex. - sleep(5); + Glib::Mutex::Lock lock(connections_mutex); connections.push_back(connection); #ifdef DEBUG std::cerr << __FILE__ << ": real_run(): lista de conexiones" << std::endl; @@ -100,7 +99,6 @@ void PlaQui::Server::TCPServer::real_run(void) { std::cerr << "\t " << *i << std::endl; } #endif // DEBUG - connections_mutex.unlock(); // Conecto la señal para cuando termina una conexión, borrarla. connection->signal_finished().connect( SigC::bind( @@ -108,6 +106,7 @@ void PlaQui::Server::TCPServer::real_run(void) { &TCPServer::on_connection_finished), connection)); connection->run(); + //connections_mutex.unlock(); // Si pongo el mutex antes del run(), muere. } }