MCPcopy Create free account
hub / github.com/F-Stack/f-stack / tcp_disconnect

Function tcp_disconnect

freebsd/netinet/tcp_usrreq.c:2651–2680  ·  view source on GitHub ↗

* Initiate (or continue) disconnect. * If embryonic state, just send reset (once). * If in ``let data drain'' option and linger null, just drop. * Otherwise (hard), mark socket disconnecting and drop * current input data; switch states based on user close, and * send segment to peer (with FIN). */

Source from the content-addressed store, hash-verified

2649 * send segment to peer (with FIN).
2650 */
2651static void
2652tcp_disconnect(struct tcpcb *tp)
2653{
2654 struct inpcb *inp = tp->t_inpcb;
2655 struct socket *so = inp->inp_socket;
2656
2657 NET_EPOCH_ASSERT();
2658 INP_WLOCK_ASSERT(inp);
2659
2660 /*
2661 * Neither tcp_close() nor tcp_drop() should return NULL, as the
2662 * socket is still open.
2663 */
2664 if (tp->t_state < TCPS_ESTABLISHED &&
2665 !(tp->t_state > TCPS_LISTEN && IS_FASTOPEN(tp->t_flags))) {
2666 tp = tcp_close(tp);
2667 KASSERT(tp != NULL,
2668 ("tcp_disconnect: tcp_close() returned NULL"));
2669 } else if ((so->so_options & SO_LINGER) && so->so_linger == 0) {
2670 tp = tcp_drop(tp, 0);
2671 KASSERT(tp != NULL,
2672 ("tcp_disconnect: tcp_drop() returned NULL"));
2673 } else {
2674 soisdisconnecting(so);
2675 sbflush(&so->so_rcv);
2676 tcp_usrclosed(tp);
2677 if (!(inp->inp_flags & INP_DROPPED))
2678 tp->t_fb->tfb_tcp_output(tp);
2679 }
2680}
2681
2682/*
2683 * User issued close, and wish to trail through shutdown states:

Callers 2

tcp_usr_disconnectFunction · 0.85
tcp_usr_closeFunction · 0.85

Calls 5

tcp_closeFunction · 0.85
tcp_dropFunction · 0.85
soisdisconnectingFunction · 0.85
sbflushFunction · 0.85
tcp_usrclosedFunction · 0.85

Tested by

no test coverage detected