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

Function event_callback

components/net/lwip/lwip-1.4.1/src/api/sockets.c:1259–1373  ·  view source on GitHub ↗

* Callback registered in the netconn layer for each socket-netconn. * Processes recvevent (data available) and wakes up tasks waiting for select. */

Source from the content-addressed store, hash-verified

1257 * Processes recvevent (data available) and wakes up tasks waiting for select.
1258 */
1259static void
1260event_callback(struct netconn *conn, enum netconn_evt evt, u16_t len)
1261{
1262 int s;
1263 struct lwip_sock *sock;
1264 struct lwip_select_cb *scb;
1265 int last_select_cb_ctr;
1266 SYS_ARCH_DECL_PROTECT(lev);
1267
1268 LWIP_UNUSED_ARG(len);
1269
1270 /* Get socket */
1271 if (conn) {
1272 s = conn->socket;
1273 if (s < 0) {
1274 /* Data comes in right away after an accept, even though
1275 * the server task might not have created a new socket yet.
1276 * Just count down (or up) if that's the case and we
1277 * will use the data later. Note that only receive events
1278 * can happen before the new socket is set up. */
1279 SYS_ARCH_PROTECT(lev);
1280 if (conn->socket < 0) {
1281 if (evt == NETCONN_EVT_RCVPLUS) {
1282 conn->socket--;
1283 }
1284 SYS_ARCH_UNPROTECT(lev);
1285 return;
1286 }
1287 s = conn->socket;
1288 SYS_ARCH_UNPROTECT(lev);
1289 }
1290
1291 sock = get_socket(s);
1292 if (!sock) {
1293 return;
1294 }
1295 } else {
1296 return;
1297 }
1298
1299 SYS_ARCH_PROTECT(lev);
1300 /* Set event as required */
1301 switch (evt) {
1302 case NETCONN_EVT_RCVPLUS:
1303 sock->rcvevent++;
1304 break;
1305 case NETCONN_EVT_RCVMINUS:
1306 sock->rcvevent--;
1307 break;
1308 case NETCONN_EVT_SENDPLUS:
1309 sock->sendevent = 1;
1310 break;
1311 case NETCONN_EVT_SENDMINUS:
1312 sock->sendevent = 0;
1313 break;
1314 case NETCONN_EVT_ERROR:
1315 sock->errevent = 1;
1316 break;

Callers

nothing calls this directly

Calls 2

get_socketFunction · 0.70
sys_sem_signalFunction · 0.50

Tested by

no test coverage detected