From 3a1d4379b2b1f9f20203f801e5fb316ef9ed3c03 Mon Sep 17 00:00:00 2001 From: Max Lv Date: Sun, 7 Feb 2021 08:58:09 +0800 Subject: [PATCH] Refine error message --- tun2socks/SocksUdpGwClient.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/tun2socks/SocksUdpGwClient.c b/tun2socks/SocksUdpGwClient.c index 842c8983..db0bf265 100644 --- a/tun2socks/SocksUdpGwClient.c +++ b/tun2socks/SocksUdpGwClient.c @@ -617,16 +617,20 @@ void SocksUdpGwClient_SubmitPacket (SocksUdpGwClient *o, BAddr local_addr, BAddr // create new connection con = connection_init(o, conaddr, data, data_len, is_dns); } else { - // move connection to front of the list - LinkedList1_Remove(&o->connections_list, &con->connections_list_node); - LinkedList1_Append(&o->connections_list, &con->connections_list_node); - // reset the connection reset_connection(o, con, conaddr, is_dns); // send packet to existing connection - // drop the packet if out of buffer - connection_send(con, data, data_len); + int res = connection_send(con, data, data_len); + + if (res == 1) { + // drop the packet if out of buffer + BLog(BLOG_ERROR, "Drop the packet as the buffer is full"); + } else { + // move connection to front of the list + LinkedList1_Remove(&o->connections_list, &con->connections_list_node); + LinkedList1_Append(&o->connections_list, &con->connections_list_node); + } } #else // submit to udpgw client