1
0
mirror of https://github.com/lxsang/antd-tunnel-plugin synced 2024-11-16 09:48:21 +01:00

Improvement stability

This commit is contained in:
lxsang 2020-12-30 14:31:08 +01:00
parent 5219d6d037
commit e1838b1f7f
2 changed files with 19 additions and 0 deletions

Binary file not shown.

View File

@ -612,6 +612,17 @@ static void handle_channel(bst_node_t *node, void **args, int argc)
if (write_msg_to_client(&msg, rq) != 0)
{
ERROR("Unable to send CTRL command to client");
// remove the client from the list
if (msg.header.type != CHANNEL_UNSUBSCRIBE)
{
// tell the other endpoint to remove the subscriber
msg.header.type = CHANNEL_UNSUBSCRIBE;
msg.header.size = 0;
if (msg_write(channel->sock, &msg) == -1)
{
ERROR("Unable to send unsubscribe notification to channel %s (%d)", channel->name, channel->sock);
}
}
}
}
}
@ -784,6 +795,14 @@ static void process_client_message(antd_tunnel_msg_t *msg, antd_client_t *client
if (msg_write(channel->sock, msg) == -1)
{
ERROR("Unable to write data to channel [%s] from client %d", channel->name, msg->header.client_id);
// notify client to unsubscribe
msg->header.type = CHANNEL_UNSUBSCRIBE;
msg->header.size = 0;
if (write_msg_to_client(msg, client) != 0)
{
ERROR("Unable to send unsubscribe message to client to client");
}
return;
}
}
}