important:

* PIThread::~PIThread() now unregister itself from introspection, if terminates than show warning
 * PISystemMonitor now correctly stops
 * PIPeer now can correctly stopAndWait
 * PIPeer::destroy(), protected method for close all eths and threads
 * new PIINTROSPECTION_STOP macro
 * Introspection now can be correctly stopped by macro, more safety

ClientServer:
 * ClientBase::close() stop and disconnect channel
 * Server clients clean-up now event-based
 * No warnings on client destructor
This commit is contained in:
2024-09-12 17:07:48 +03:00
parent da4b09be9e
commit 996b7ea403
17 changed files with 189 additions and 99 deletions

View File

@@ -44,7 +44,7 @@ protected:
virtual void aboutDelete() {}
private:
void createForServer(PIEthernet * tcp_);
void createForServer(Server * parent, PIEthernet * tcp_);
};

View File

@@ -45,7 +45,7 @@ public:
const PIEthernet * getTCP() const { return tcp; }
void stop();
void close();
int write(const void * d, const size_t s);
int write(const PIByteArray & ba) { return write(ba.data(), ba.size()); }

View File

@@ -28,6 +28,7 @@
#include "pimutex.h"
#include "pinetworkaddress.h"
#include "pip_client_server_export.h"
#include "pithreadnotifier.h"
class PIEthernet;
class PIThread;
@@ -37,6 +38,9 @@ namespace PIClientServer {
class ServerClient;
class PIP_CLIENT_SERVER_EXPORT Server {
friend class ServerClient;
NO_COPY_CLASS(Server);
public:
Server();
virtual ~Server();
@@ -56,11 +60,13 @@ public:
private:
void stopServer();
void newClient(ServerClient * c);
void clientDisconnected(ServerClient * c);
std::function<ServerClient *()> client_factory;
std::atomic_bool is_closing = {false};
PIEthernet * tcp_server = nullptr;
PIThread * clean_thread = nullptr;
PIThreadNotifier clean_notifier;
PIByteArray crypt_key;
PIVector<ServerClient *> clients;
mutable PIMutex clients_mutex;