X-Git-Url: https://git.llucax.com/z.facultad/75.42/plaqui.git/blobdiff_plain/292425c2f65528535f137b437e629c5785c870d0..cd6078479123cd2cfe62df2d838633c143649edf:/Server/src/tcpserver.cpp?ds=sidebyside diff --git a/Server/src/tcpserver.cpp b/Server/src/tcpserver.cpp index d2bb7fd..861b6ee 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,7 @@ 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); connections.remove(connection); #ifdef DEBUG std::cerr << __FILE__ << ": lista de conexiones" << std::endl; @@ -73,7 +73,6 @@ void PlaQui::Server::TCPServer::on_connection_finished( std::cerr << "\t " << *i << std::endl; } #endif // DEBUG - connections_mutex.unlock(); } /// \todo TODO: ver tema de timeout o como salir de un accept(). @@ -89,9 +88,8 @@ 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); + // XXX connections_mutex.lock(); connections.push_back(connection); #ifdef DEBUG std::cerr << __FILE__ << ": real_run(): lista de conexiones" << std::endl; @@ -100,7 +98,7 @@ void PlaQui::Server::TCPServer::real_run(void) { std::cerr << "\t " << *i << std::endl; } #endif // DEBUG - connections_mutex.unlock(); + // XXX connections_mutex.unlock(); // Si pongo el mutex antes del run(), muere. // Conecto la señal para cuando termina una conexión, borrarla. connection->signal_finished().connect( SigC::bind(