MCPcopy Create free account
hub / github.com/RT-Thread/rt-thread / event_callback

Function event_callback

components/net/sal/impl/af_inet_lwip.c:86–172  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

84extern struct lwip_sock *lwip_tryget_socket(int s);
85
86static void event_callback(struct netconn *conn, enum netconn_evt evt, u16_t len)
87{
88 int s;
89 struct lwip_sock *sock;
90 uint32_t event = 0;
91 SYS_ARCH_DECL_PROTECT(lev);
92
93 LWIP_UNUSED_ARG(len);
94
95 /* Get socket */
96 if (conn)
97 {
98 s = conn->socket;
99 if (s < 0)
100 {
101 /* Data comes in right away after an accept, even though
102 * the server task might not have created a new socket yet.
103 * Just count down (or up) if that's the case and we
104 * will use the data later. Note that only receive events
105 * can happen before the new socket is set up. */
106 SYS_ARCH_PROTECT(lev);
107 if (conn->socket < 0)
108 {
109 if (evt == NETCONN_EVT_RCVPLUS)
110 {
111 conn->socket--;
112 }
113 SYS_ARCH_UNPROTECT(lev);
114 return;
115 }
116 s = conn->socket;
117 SYS_ARCH_UNPROTECT(lev);
118 }
119
120 sock = lwip_tryget_socket(s);
121 if (!sock)
122 {
123 return;
124 }
125 }
126 else
127 {
128 return;
129 }
130
131 SYS_ARCH_PROTECT(lev);
132 /* Set event as required */
133 switch (evt)
134 {
135 case NETCONN_EVT_RCVPLUS:
136 sock->rcvevent++;
137 break;
138 case NETCONN_EVT_RCVMINUS:
139 sock->rcvevent--;
140 break;
141 case NETCONN_EVT_SENDPLUS:
142 sock->sendevent = 1;
143 break;

Callers

nothing calls this directly

Calls 2

rt_wqueue_wakeupFunction · 0.85
lwip_tryget_socketFunction · 0.50

Tested by

no test coverage detected