1
0
Fork 0
forked from lthn/blockchain

fixed bug with dummy server destructor being nasty

This commit is contained in:
cryptozoidberg 2025-03-10 13:56:48 +04:00
parent 6b152827af
commit d93624bbf4
No known key found for this signature in database
GPG key ID: 2E10CC61CAC8F36D
2 changed files with 10 additions and 2 deletions

View file

@ -86,9 +86,16 @@ namespace levin
virtual void on_connection_new(t_connection_context& context){};
virtual void on_connection_close(t_connection_context& context){};
};
template<class t_connection_context = net_utils::connection_context_base>
struct levin_commands_handler_dummy: public levin_commands_handler<t_connection_context>
{
virtual int invoke(int command, const std::string& in_buff, std::string& buff_out, t_connection_context& context) { return LEVIN_OK; }
virtual int notify(int command, const std::string& in_buff, t_connection_context& context) { return LEVIN_OK; }
};
#define LEVIN_OK 0
#define LEVIN_ERROR_CONNECTION -1
#define LEVIN_ERROR_CONNECTION_NOT_FOUND -2

View file

@ -59,6 +59,7 @@ class async_protocol_handler_config
critical_section m_connects_lock;
std::atomic<bool> m_is_in_sendstop_loop;
connections_map m_connects;
levin_commands_handler_dummy<t_connection_context> m_commands_handler_dummy;
void add_connection(async_protocol_handler<t_connection_context>* pc);
void del_connection(async_protocol_handler<t_connection_context>* pc);
@ -87,7 +88,7 @@ public:
bool foreach_connection(callback_t cb);
size_t get_connections_count();
async_protocol_handler_config() :m_pcommands_handler(NULL), m_max_packet_size(LEVIN_DEFAULT_MAX_PACKET_SIZE), m_is_in_sendstop_loop(false), m_invoke_timeout{}
async_protocol_handler_config() :m_pcommands_handler(&m_commands_handler_dummy), m_max_packet_size(LEVIN_DEFAULT_MAX_PACKET_SIZE), m_is_in_sendstop_loop(false), m_invoke_timeout{}
{}
~async_protocol_handler_config()
{