diff --git a/xkcp_mon.c b/xkcp_mon.c index e717d67..0d2cb83 100644 --- a/xkcp_mon.c +++ b/xkcp_mon.c @@ -83,7 +83,7 @@ static void get_client_info(struct bufferevent *bev, void *ctx) jwHashEntry *entry = xkcp_hash->bucket[i]; while (entry) { evbuffer_add_printf(output, "hash_id [%d] connected client [%s] connection [%d] \n", - i, entry->key.strValue, get_task_list_size(entry->key.ptrValue)); + i, entry->key.strValue, get_task_list_size(entry->value.ptrValue)); entry = entry->next; } } diff --git a/xkcp_util.c b/xkcp_util.c index 19f9cc1..f516567 100644 --- a/xkcp_util.c +++ b/xkcp_util.c @@ -227,6 +227,19 @@ static void dump_task(struct xkcp_task *task, struct bufferevent *bev, int index ikcp_peeksize(task->kcp), task->kcp->stream); } +int get_task_list_size(iqueue_head *task_list) +{ + struct xkcp_task *task; + int num = 0; + iqueue_foreach(task, task_list, xkcp_task_type, head) { + if (task->kcp) { + num++; + } + } + + return num; +} + void dump_task_list(iqueue_head *task_list, struct bufferevent *bev) { struct xkcp_task *task; task_list_count = 0; diff --git a/xkcp_util.h b/xkcp_util.h index ef253d5..f1fbd89 100644 --- a/xkcp_util.h +++ b/xkcp_util.h @@ -42,6 +42,8 @@ void add_task_tail(struct xkcp_task *task, iqueue_head *head); void del_task(struct xkcp_task *task); +int get_task_list_size(iqueue_head *task_list); + void dump_task_list(iqueue_head *task_list, struct bufferevent *bev); void xkcp_set_config_param(ikcpcb *kcp);