Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 11 May 1999 17:10:37 +0530 (IST)
From:      Abhinandan R Ekande <abhire@wipro.wipsys.soft.net>
To:        ajit@wipinfo.soft.net (Ajit Shimpi)
Cc:        freebsd-net@FreeBSD.ORG
Subject:   Re: socket close()
Message-ID:  <199905111140.RAA04307@wipro.wipsys.sequent.com>
In-Reply-To: <Pine.LNX.4.05.9905111541190.21167-100000@voyager.wipinfo.soft.net> from "Ajit Shimpi" at May 11, 1999 03:42:50 PM

next in thread | previous in thread | raw e-mail | index | archive | help
Hi,

When we do a close on socket in established state, we enter
TCPS_FIN_WAIT_1 state. From there we have to reach TCPS_TIME_WAIT
state either directly or after TCPS_FIN_WAIT_2. Please refer
TCP state diagram TCP/IP Illustrated Vol. 2.
Connection remains in TIME_WAIT state for 2 * MSL time.
When this timer fires, we enter the following code fragment :

File : netinet/tcp_timer.c 

case TCPT_2MSL:
                if (tp->t_state != TCPS_TIME_WAIT &&
                    tp->t_idle <= tcp_maxidle)
                        tp->t_timer[TCPT_2MSL] = tcp_keepintvl;
                else
                        tp = tcp_close(tp);
                break;

Here tcp_close() is called and it does all the freeing stuff.


Thanks,
- Abhi.

. Hi,
. 
.     I am going through socket layer implementation of close() system call
. (4.4BSD Lite-2 sources). In the function soclose()
. (file : kern/uipc_socket.c), sofree() is called. In sofree(), one
.  of the first checks made is whether so->so_pcb field of socket structure
. (so) is NULL. This, I feel, is non-null, since soclose() calls
. PRU_DISCONNECT and then PRU_DETACH user requests. The tcp_usrreq()
. function handles these requests by calling tcp_disconnect() for
. connection in ESTABLISHED state.
. 
.    If the "so_pcb" field is non-null, sofree() returns without freeing
. socket structure (so).
. 
.    Can anyone explain if the PCB associated with the socket is freed for
. ESABLISHED connections? Or is it a defect?
. 
. [  Btw, tcp_close() does all the freeing job; but is never called for TCP
. connections in ESTABLISHED state.]
. 
. Thanks in advance,
. 
. Ajit.
. 
. 
. 
. To Unsubscribe: send mail to majordomo@FreeBSD.org
. with "unsubscribe freebsd-net" in the body of the message
. 



To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-net" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199905111140.RAA04307>