From f1f2d6a48b96c759d197d1227e157665d0d7bbcc Mon Sep 17 00:00:00 2001 From: Leandro Lucarella Date: Fri, 24 Oct 2003 05:22:56 +0000 Subject: [PATCH] Se unlockea() el mutex despues de llamar a connection->run(). Si lo unlockeo() antes, se muere con segfault cuando se conectan 2 clientes exactamente al mismo tiempo. Esto no deberia ser asi, al menos eso creo, seguire investigando... --- Server/src/tcpserver.cpp | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) 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. } } -- 2.43.0