|
|
|
@ -40,7 +40,6 @@ static void retry_timer_cb(void* arg); |
|
|
|
static int send_msg(struct UTUN_INSTANCE* inst, uint64_t group_id, uint64_t dst, uint8_t subcmd, |
|
|
|
static int send_msg(struct UTUN_INSTANCE* inst, uint64_t group_id, uint64_t dst, uint8_t subcmd, |
|
|
|
uint32_t sid, const uint8_t* data, size_t len, int force); |
|
|
|
uint32_t sid, const uint8_t* data, size_t len, int force); |
|
|
|
static void send_close(struct tcp_proxy_server_conn* rc); |
|
|
|
static void send_close(struct tcp_proxy_server_conn* rc); |
|
|
|
static void send_error(struct tcp_proxy_server_conn* rc); |
|
|
|
|
|
|
|
void tcp_proxy_server_conn_free(struct tcp_proxy_server_conn* rc); |
|
|
|
void tcp_proxy_server_conn_free(struct tcp_proxy_server_conn* rc); |
|
|
|
|
|
|
|
|
|
|
|
static inline int write_pending(struct tcp_conn* tc) { |
|
|
|
static inline int write_pending(struct tcp_conn* tc) { |
|
|
|
@ -96,17 +95,6 @@ static void send_close(struct tcp_proxy_server_conn* rc) { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
static void send_error(struct tcp_proxy_server_conn* rc) { |
|
|
|
|
|
|
|
struct UTUN_INSTANCE* inst = rc->ctx ? rc->ctx->inst : NULL; |
|
|
|
|
|
|
|
if (!inst) return; |
|
|
|
|
|
|
|
if (send_msg(inst, TOPO_GROUP_UTUN, rc->peer_node_id, TCP_PROXY_SUBCMD_ERROR, rc->stream_id, NULL, 0, 1) < 0) { |
|
|
|
|
|
|
|
rc->close_pending = 1; |
|
|
|
|
|
|
|
rc->close_backoff = 50; |
|
|
|
|
|
|
|
if (!rc->close_timer) |
|
|
|
|
|
|
|
rc->close_timer = uasync_set_timeout(rc->ua, rc->close_backoff, rc, close_retry_cb, "tps_close_retry"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static void send_fin(struct tcp_proxy_server_conn* rc) { |
|
|
|
static void send_fin(struct tcp_proxy_server_conn* rc) { |
|
|
|
struct UTUN_INSTANCE* inst = rc->ctx ? rc->ctx->inst : NULL; |
|
|
|
struct UTUN_INSTANCE* inst = rc->ctx ? rc->ctx->inst : NULL; |
|
|
|
if (!inst) return; |
|
|
|
if (!inst) return; |
|
|
|
@ -175,8 +163,11 @@ static void on_error_cb(struct tcp_conn* tc, int err, void* arg) { |
|
|
|
rc->drain_count, rc->data_count, |
|
|
|
rc->drain_count, rc->data_count, |
|
|
|
tc ? tc->read_queue->count : 0, tc ? tc->write_queue->count : 0, |
|
|
|
tc ? tc->read_queue->count : 0, tc ? tc->write_queue->count : 0, |
|
|
|
tc && tc->write_buf ? "y" : "n", tc ? tc->connected : 0); |
|
|
|
tc && tc->write_buf ? "y" : "n", tc ? tc->connected : 0); |
|
|
|
send_error(rc); |
|
|
|
struct UTUN_INSTANCE* inst = rc->ctx ? rc->ctx->inst : NULL; |
|
|
|
|
|
|
|
uint64_t peer = rc->peer_node_id; |
|
|
|
|
|
|
|
uint32_t sid = rc->stream_id; |
|
|
|
tcp_proxy_server_conn_free(rc); |
|
|
|
tcp_proxy_server_conn_free(rc); |
|
|
|
|
|
|
|
if (inst) send_msg(inst, TOPO_GROUP_UTUN, peer, TCP_PROXY_SUBCMD_ERROR, sid, NULL, 0, 1); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
static void diag_timer_cb(void* arg) { |
|
|
|
static void diag_timer_cb(void* arg) { |
|
|
|
|