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

Function done_socket

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

In full-duplex mode,sock->fd_used != 0 prevents a socket descriptor from being * released (and possibly reused) when used from more than one thread * (e.g. read-while-write or close-while-write, etc) * This function is called at the end of functions using (try)get_socket*(). */

Source from the content-addressed store, hash-verified

374 * This function is called at the end of functions using (try)get_socket*().
375 */
376static void
377done_socket(struct lwip_sock *sock)
378{
379 int freed = 0;
380 int is_tcp = 0;
381 struct netconn *conn = NULL;
382 union lwip_sock_lastdata lastdata;
383 SYS_ARCH_DECL_PROTECT(lev);
384 LWIP_ASSERT("sock != NULL", sock != NULL);
385
386 SYS_ARCH_PROTECT(lev);
387 LWIP_ASSERT("sock->fd_used > 0", sock->fd_used > 0);
388 if (--sock->fd_used == 0) {
389 if (sock->fd_free_pending) {
390 /* free the socket */
391 sock->fd_used = 1;
392 is_tcp = sock->fd_free_pending & LWIP_SOCK_FD_FREE_TCP;
393 freed = free_socket_locked(sock, is_tcp, &conn, &lastdata);
394 }
395 }
396 SYS_ARCH_UNPROTECT(lev);
397
398 if (freed) {
399 free_socket_free_elements(is_tcp, conn, &lastdata);
400 }
401}
402
403#else /* LWIP_NETCONN_FULLDUPLEX */
404#define sock_inc_used(sock) 1

Callers 15

tryget_socketFunction · 0.85
lwip_tryget_socketFunction · 0.85
lwip_acceptFunction · 0.85
lwip_bindFunction · 0.85
lwip_closeFunction · 0.85
lwip_connectFunction · 0.85
lwip_listenFunction · 0.85
lwip_recvfromFunction · 0.85
lwip_recvmsgFunction · 0.85
lwip_sendFunction · 0.85
lwip_sendmsgFunction · 0.85
lwip_sendtoFunction · 0.85

Calls 2

free_socket_lockedFunction · 0.85

Tested by

no test coverage detected