From owner-freebsd-net Tue May 11 4:32:51 1999 Delivered-To: freebsd-net@freebsd.org Received: from dwarpal.wipsys.soft.net (dwarpal.wipsys.soft.net [164.164.127.8]) by hub.freebsd.org (Postfix) with SMTP id 18A2C14D85 for ; Tue, 11 May 1999 04:32:39 -0700 (PDT) (envelope-from abhire@wipro.wipsys.soft.net) Received: by dwarpal.wipsys.soft.net (SMI-8.6/SMI-SVR4) id RAA00451; Tue, 11 May 1999 17:00:28 +0530 Received: from benz.wipsys.soft.net(164.164.27.140) by dwarpal via smap (V2.0) id xma000421; Tue, 11 May 99 17:00:14 +0530 Received: from sidcgw.wipsys.soft.net (localhost [127.0.0.1]) by benz.wipsys.soft.net (8.9.1/8.9.1) with ESMTP id QAA09982; Tue, 11 May 1999 16:47:00 -0500 (GMT) Received: from wipro.wipsys.sequent.com (wipro.wipsys.sequent.com [192.84.36.6]) by sidcgw.wipsys.soft.net (8.8.5/8.8.5) with ESMTP id QAA09324; Tue, 11 May 1999 16:57:53 +0530 Received: (from abhire@localhost) by wipro.wipsys.sequent.com (8.8.5/8.8.5) id RAA04307; Tue, 11 May 1999 17:10:37 +0530 (IST) From: Abhinandan R Ekande Message-Id: <199905111140.RAA04307@wipro.wipsys.sequent.com> Subject: Re: socket close() To: ajit@wipinfo.soft.net (Ajit Shimpi) Date: Tue, 11 May 1999 17:10:37 +0530 (IST) Cc: freebsd-net@FreeBSD.ORG In-Reply-To: from "Ajit Shimpi" at May 11, 1999 03:42:50 PM X-Mailer: ELM [version 2.5 PL0b1] MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Sender: owner-freebsd-net@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.org 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