diff --git a/lib/tcp_socket.hpp b/lib/tcp_socket.hpp index 4927772..ce5261f 100644 --- a/lib/tcp_socket.hpp +++ b/lib/tcp_socket.hpp @@ -36,7 +36,7 @@ class server { ~server (); // one klijent - client* cli; + client* cli = NULL; void accept(const uint timeout = 100); vector thr; diff --git a/src/tcp_socket.cpp b/src/tcp_socket.cpp index 3b31296..5cdf4e9 100644 --- a/src/tcp_socket.cpp +++ b/src/tcp_socket.cpp @@ -5,7 +5,8 @@ */ server::server (const ushort port, const uint limit, SSL_CTX* _securefds) { - securefds = _securefds; + securefds = _securefds; // dodati parametar red čekanja queue koji će se koristiti kao limit u socketu + // a stavrni limit ćemo korisitit kao broj threadova addr.sin_family = AF_INET; addr.sin_addr.s_addr = INADDR_ANY; @@ -33,14 +34,16 @@ server::server (const ushort port, const uint limit, SSL_CTX* _securefds) { } void server::accept(const uint timeout) { + if (cli != NULL) { + cli->~client(); + cli = NULL; + } cli = new client(this, timeout, securefds); } void server::asyncli(const uint limit, void (*handlecli)(client*), const uint timeout) { do { - thr.clear(); - clis.clear(); for (uint i=0; i~client(); } + thr.clear(); + clis.clear(); } while (true); } diff --git a/test/client.o b/test/client.o index dfb7342..d18a994 100755 Binary files a/test/client.o and b/test/client.o differ diff --git a/test/server.o b/test/server.o index a20c7d0..5a4e551 100755 Binary files a/test/server.o and b/test/server.o differ