124 lines
3.6 KiB
Diff
124 lines
3.6 KiB
Diff
From e719fde7f90a1dff8daeb23170febb5ff38903c9 Mon Sep 17 00:00:00 2001
|
|
From: jiangheng <jiangheng14@huawei.com>
|
|
Date: Fri, 27 Oct 2023 19:19:42 +0800
|
|
Subject: [PATCH 77/77] adpat event for rtc mode
|
|
|
|
---
|
|
src/api/api_msg.c | 8 ++------
|
|
src/api/sockets.c | 33 ++++++++++++++++++++++++++++++---
|
|
src/include/eventpoll.h | 4 ++++
|
|
3 files changed, 36 insertions(+), 9 deletions(-)
|
|
|
|
diff --git a/src/api/api_msg.c b/src/api/api_msg.c
|
|
index 9a8992a..5e09505 100644
|
|
--- a/src/api/api_msg.c
|
|
+++ b/src/api/api_msg.c
|
|
@@ -293,11 +293,9 @@ recv_udp(void *arg, struct udp_pcb *pcb, struct pbuf *p,
|
|
#endif /* LWIP_SO_RCVBUF */
|
|
#if GAZELLE_UDP_ENABLE
|
|
do_lwip_add_recvlist(conn->socket);
|
|
- LWIP_UNUSED_ARG(len);
|
|
-#else /* GAZELLE_UDP_ENABLE */
|
|
+#endif /* GAZELLE_UDP_ENABLE */
|
|
/* Register event with callback */
|
|
API_EVENT(conn, NETCONN_EVT_RCVPLUS, len);
|
|
-#endif /* GAZELLE_UDP_ENABLE */
|
|
}
|
|
}
|
|
#endif /* LWIP_UDP */
|
|
@@ -357,11 +355,9 @@ recv_tcp(void *arg, struct tcp_pcb *pcb, struct pbuf *p, err_t err)
|
|
#endif /* LWIP_SO_RCVBUF */
|
|
#if GAZELLE_ENABLE
|
|
do_lwip_add_recvlist(conn->socket);
|
|
- LWIP_UNUSED_ARG(len);
|
|
-#else
|
|
+#endif
|
|
/* Register event with callback */
|
|
API_EVENT(conn, NETCONN_EVT_RCVPLUS, len);
|
|
-#endif
|
|
}
|
|
|
|
return ERR_OK;
|
|
diff --git a/src/api/sockets.c b/src/api/sockets.c
|
|
index 1d71427..d62290d 100644
|
|
--- a/src/api/sockets.c
|
|
+++ b/src/api/sockets.c
|
|
@@ -2744,29 +2744,56 @@ event_callback(struct netconn *conn, enum netconn_evt evt, u16_t len)
|
|
check_waiters = 0;
|
|
}
|
|
#if GAZELLE_ENABLE
|
|
- if (conn->acceptmbox != NULL && !sys_mbox_empty(conn->acceptmbox)) {
|
|
- add_sock_event(sock, POLLIN);
|
|
+ if (netif_is_rtc_mode(netif_default)) {
|
|
+ if (sock->rcvevent == 1) {
|
|
+ add_sock_event_nolock(sock, POLLIN);
|
|
+ }
|
|
+ } else {
|
|
+ if (conn->acceptmbox != NULL && !sys_mbox_empty(conn->acceptmbox)) {
|
|
+ add_sock_event(sock, POLLIN);
|
|
+ }
|
|
}
|
|
#endif
|
|
break;
|
|
case NETCONN_EVT_RCVMINUS:
|
|
sock->rcvevent--;
|
|
check_waiters = 0;
|
|
+#if GAZELLE_ENABLE
|
|
+ if (netif_is_rtc_mode(netif_default)) {
|
|
+ if (sock->rcvevent == 0) {
|
|
+ del_sock_event_nolock(sock, POLLIN);
|
|
+ }
|
|
+ }
|
|
+#endif
|
|
break;
|
|
case NETCONN_EVT_SENDPLUS:
|
|
if (sock->sendevent) {
|
|
check_waiters = 0;
|
|
}
|
|
sock->sendevent = 1;
|
|
+#if GAZELLE_ENABLE
|
|
+ if (netif_is_rtc_mode(netif_default)) {
|
|
+ add_sock_event_nolock(sock, POLLOUT);
|
|
+ }
|
|
+#endif
|
|
break;
|
|
case NETCONN_EVT_SENDMINUS:
|
|
sock->sendevent = 0;
|
|
check_waiters = 0;
|
|
+#if GAZELLE_ENABLE
|
|
+ if (netif_is_rtc_mode(netif_default)) {
|
|
+ del_sock_event_nolock(sock, POLLOUT);
|
|
+ }
|
|
+#endif
|
|
break;
|
|
case NETCONN_EVT_ERROR:
|
|
sock->errevent = 1;
|
|
#if GAZELLE_ENABLE
|
|
- add_sock_event(sock, EPOLLERR);
|
|
+ if (netif_is_rtc_mode(netif_default)) {
|
|
+ add_sock_event_nolock(sock, EPOLLERR);
|
|
+ } else {
|
|
+ add_sock_event(sock, EPOLLERR);
|
|
+ }
|
|
#endif
|
|
break;
|
|
default:
|
|
diff --git a/src/include/eventpoll.h b/src/include/eventpoll.h
|
|
index dd65a4d..5bc5206 100644
|
|
--- a/src/include/eventpoll.h
|
|
+++ b/src/include/eventpoll.h
|
|
@@ -66,6 +66,10 @@ struct libos_epoll {
|
|
|
|
struct lwip_sock;
|
|
extern void add_sock_event(struct lwip_sock *sock, uint32_t event);
|
|
+extern void add_sock_event_nolock(struct lwip_sock *sock, uint32_t event);
|
|
+extern void del_sock_event(struct lwip_sock *sock, uint32_t event);
|
|
+extern void del_sock_event_nolock(struct lwip_sock *sock, uint32_t event);
|
|
+
|
|
extern int32_t lstack_epoll_close(int32_t);
|
|
|
|
#endif /* __EVENTPOLL_H__ */
|
|
--
|
|
2.27.0
|
|
|