* Callback registered in the netconn layer for each socket-netconn. * Processes recvevent (data available) and wakes up tasks waiting for select. * * @note for LWIP_TCPIP_CORE_LOCKING any caller of this function * must have the core lock held when signaling the following events * as they might cause select_list_cb to be checked: * NETCONN_EVT_RCVPLUS * NETCONN_EVT_SENDPLUS * NETCONN_
| 2496 | * This requirement will be asserted in select_check_waiters() |
| 2497 | */ |
| 2498 | static void |
| 2499 | event_callback(struct netconn *conn, enum netconn_evt evt, u16_t len) |
| 2500 | { |
| 2501 | int s, check_waiters; |
| 2502 | struct lwip_sock *sock; |
| 2503 | SYS_ARCH_DECL_PROTECT(lev); |
| 2504 | |
| 2505 | LWIP_UNUSED_ARG(len); |
| 2506 | |
| 2507 | /* Get socket */ |
| 2508 | if (conn) { |
| 2509 | s = conn->socket; |
| 2510 | if (s < 0) { |
| 2511 | /* Data comes in right away after an accept, even though |
| 2512 | * the server task might not have created a new socket yet. |
| 2513 | * Just count down (or up) if that's the case and we |
| 2514 | * will use the data later. Note that only receive events |
| 2515 | * can happen before the new socket is set up. */ |
| 2516 | SYS_ARCH_PROTECT(lev); |
| 2517 | if (conn->socket < 0) { |
| 2518 | if (evt == NETCONN_EVT_RCVPLUS) { |
| 2519 | /* conn->socket is -1 on initialization |
| 2520 | lwip_accept adjusts sock->recvevent if conn->socket < -1 */ |
| 2521 | conn->socket--; |
| 2522 | } |
| 2523 | SYS_ARCH_UNPROTECT(lev); |
| 2524 | return; |
| 2525 | } |
| 2526 | s = conn->socket; |
| 2527 | SYS_ARCH_UNPROTECT(lev); |
| 2528 | } |
| 2529 | |
| 2530 | sock = get_socket(s); |
| 2531 | if (!sock) { |
| 2532 | return; |
| 2533 | } |
| 2534 | } else { |
| 2535 | return; |
| 2536 | } |
| 2537 | |
| 2538 | check_waiters = 1; |
| 2539 | SYS_ARCH_PROTECT(lev); |
| 2540 | /* Set event as required */ |
| 2541 | switch (evt) { |
| 2542 | case NETCONN_EVT_RCVPLUS: |
| 2543 | sock->rcvevent++; |
| 2544 | if (sock->rcvevent > 1) { |
| 2545 | check_waiters = 0; |
| 2546 | } |
| 2547 | break; |
| 2548 | case NETCONN_EVT_RCVMINUS: |
| 2549 | sock->rcvevent--; |
| 2550 | check_waiters = 0; |
| 2551 | break; |
| 2552 | case NETCONN_EVT_SENDPLUS: |
| 2553 | if (sock->sendevent) { |
| 2554 | check_waiters = 0; |
| 2555 | } |
nothing calls this directly
no test coverage detected