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

Function free_socket_locked

components/net/lwip/lwip-2.1.2/src/api/sockets.c:569–589  ·  view source on GitHub ↗

Free a socket (under lock) * * @param sock the socket to free * @param is_tcp != 0 for TCP sockets, used to free lastdata * @param conn the socekt's netconn is stored here, must be freed externally * @param lastdata lastdata is stored here, must be freed externally */

Source from the content-addressed store, hash-verified

567 * @param lastdata lastdata is stored here, must be freed externally
568 */
569static int
570free_socket_locked(struct lwip_sock *sock, int is_tcp, struct netconn **conn,
571 union lwip_sock_lastdata *lastdata)
572{
573#if LWIP_NETCONN_FULLDUPLEX
574 LWIP_ASSERT("sock->fd_used > 0", sock->fd_used > 0);
575 sock->fd_used--;
576 if (sock->fd_used > 0) {
577 sock->fd_free_pending = LWIP_SOCK_FD_FREE_FREE | (is_tcp ? LWIP_SOCK_FD_FREE_TCP : 0);
578 return 0;
579 }
580#else /* LWIP_NETCONN_FULLDUPLEX */
581 LWIP_UNUSED_ARG(is_tcp);
582#endif /* LWIP_NETCONN_FULLDUPLEX */
583
584 *lastdata = sock->lastdata;
585 sock->lastdata.pbuf = NULL;
586 *conn = sock->conn;
587 sock->conn = NULL;
588 return 1;
589}
590
591/** Free a socket's leftover members.
592 */

Callers 2

done_socketFunction · 0.85
free_socketFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected