已合并
[Feat] epoll/poll/seleclt malloc optimize #241
xhpintell创建于 2 天前
[Feat] epoll/poll/seleclt malloc optimize #241
已合并
xhpintell创建于 2 天前
5 个文件变更+8-8
Msrc/knet/sal/tcp/tcp_api/tcp_event/include/tcp_event.h+1-1
@@ -20,7 +20,7 @@ extern "C" {
20#endif20#endif
21 21 
22#define KNET_EPOLL_MAX_NUM (((uint32_t)0xFFFFFFFF) / sizeof(struct epoll_event))22#define KNET_EPOLL_MAX_NUM (((uint32_t)0xFFFFFFFF) / sizeof(struct epoll_event))
23#define KNET_POLL_MAX_NUM 1024 // POLL最大监听文件描述符数量,KNET性能很差,不建议使用23#define KNET_POLL_MAX_NUM 8192 // POLL最大监听文件描述符数量,KNET性能很差,不建议使用
24 24 
25 25 
26/**26/**
Msrc/stack/tcp/src/dpitf/epoll/src/epoll.c+2-2
@@ -88,7 +88,7 @@ static void DisableSockNotify(EpollItem_t* item)
88 SockNotify_t* notify = GetEpollNotify(sk, item->epfd);88 SockNotify_t* notify = GetEpollNotify(sk, item->epfd);
89 if (notify != NULL) {89 if (notify != NULL) {
90 LIST_REMOVE(&sk->notifyList, notify, node);90 LIST_REMOVE(&sk->notifyList, notify, node);
91 SHM_FREE(notify, DP_MEM_FREE);91 OS_FREE(notify);
92 }92 }
93 SOCK_Unlock(sk);93 SOCK_Unlock(sk);
94 FD_Put(skFile);94 FD_Put(skFile);
@@ -511,7 +511,7 @@ static int DeleteEpollItem(Sock_t* sk, int epfd)
511 SHM_FREE(item, DP_MEM_FREE);511 SHM_FREE(item, DP_MEM_FREE);
512 512
513 LIST_REMOVE(&sk->notifyList, notify, node);513 LIST_REMOVE(&sk->notifyList, notify, node);
514 SHM_FREE(notify, DP_MEM_FREE);514 OS_FREE(notify);
515 return 0;515 return 0;
516 }516 }
517 517 
Msrc/stack/tcp/src/dpitf/poll/src/poll.c+1-1
@@ -211,7 +211,7 @@ static void DisableNotifySafe(Sock_t *sk, struct DP_Pollfd *pollFd)
211 next = LIST_NEXT(notify, node);211 next = LIST_NEXT(notify, node);
212 if (notify->notifyType == SOCK_NOTIFY_TYPE_POLL && notify->associateFd == (uint64_t)(uintptr_t)pollFd) {212 if (notify->notifyType == SOCK_NOTIFY_TYPE_POLL && notify->associateFd == (uint64_t)(uintptr_t)pollFd) {
213 LIST_REMOVE(&sk->notifyList, notify, node);213 LIST_REMOVE(&sk->notifyList, notify, node);
214 SHM_FREE(notify, DP_MEM_FREE);214 OS_FREE(notify);
215 break;215 break;
216 }216 }
217 }217 }
Msrc/stack/tcp/src/dpitf/select/src/select.c+1-1
@@ -331,7 +331,7 @@ static void DisableNotifySafe(Sock_t *sk, SelectCtx_t *ctx)
331 next = LIST_NEXT(notify, node);331 next = LIST_NEXT(notify, node);
332 if (notify->notifyType == SOCK_NOTIFY_TYPE_SELECT && notify->notifyCtx == ctx) {332 if (notify->notifyType == SOCK_NOTIFY_TYPE_SELECT && notify->notifyCtx == ctx) {
333 LIST_REMOVE(&sk->notifyList, notify, node);333 LIST_REMOVE(&sk->notifyList, notify, node);
334 SHM_FREE(notify, DP_MEM_FREE);334 OS_FREE(notify);
335 break;335 break;
336 }336 }
337 }337 }
Msrc/stack/tcp/src/dpitf/socket/src/sock.c+3-3
@@ -1797,7 +1797,7 @@ int SOCK_EnableNotify(Sock_t* sk, int type, void* ctx, uint64_t assocFd)
1797 if (type <= SOCK_NOTIFY_TYPE_NONE || type >= SOCK_NOTIFY_TYPE_MAX) {1797 if (type <= SOCK_NOTIFY_TYPE_NONE || type >= SOCK_NOTIFY_TYPE_MAX) {
1798 return -1;1798 return -1;
1799 }1799 }
1800 SockNotify_t* notify = SHM_MALLOC(sizeof(SockNotify_t), MOD_SOCKET, DP_MEM_FREE);1800 SockNotify_t* notify = OS_MALLOC(sizeof(SockNotify_t));
1801 if(notify == NULL) {1801 if(notify == NULL) {
1802 DP_LOG_ERR("Malloc memory failed for socket notify");1802 DP_LOG_ERR("Malloc memory failed for socket notify");
1803 return ENOMEM;1803 return ENOMEM;
@@ -1826,7 +1826,7 @@ void SOCK_DisableNotify(Sock_t* sk)
1826 for(notify = LIST_FIRST(&sk->notifyList); notify != NULL; notify = next) {1826 for(notify = LIST_FIRST(&sk->notifyList); notify != NULL; notify = next) {
1827 next = LIST_NEXT(notify, node);1827 next = LIST_NEXT(notify, node);
1828 LIST_REMOVE(&sk->notifyList, notify, node);1828 LIST_REMOVE(&sk->notifyList, notify, node);
1829 SHM_FREE(notify, DP_MEM_FREE);1829 OS_FREE(notify);
1830 }1830 }
1831}1831}
1832 1832 
@@ -1838,7 +1838,7 @@ void SOCK_DisableNotifyWithoutHook(Sock_t* sk)
1838 next = LIST_NEXT(notify, node);1838 next = LIST_NEXT(notify, node);
1839 if (notify->notifyType != SOCK_NOTIFY_TYPE_HOOK) {1839 if (notify->notifyType != SOCK_NOTIFY_TYPE_HOOK) {
1840 LIST_REMOVE(&sk->notifyList, notify, node);1840 LIST_REMOVE(&sk->notifyList, notify, node);
1841 SHM_FREE(notify, DP_MEM_FREE);1841 OS_FREE(notify);
1842 }1842 }
1843 }1843 }
1844}1844}