Unhang TCP connections stuck in FIN_WAIT_2 state

Steve D. Miller steve at umcp-cs.UUCP
Fri Feb 7 00:28:24 AEST 1986


   Here's a better fix for the 4.2 FIN_WAIT_2 problem.  I don't remember
where I got it, but it works; the basic problem is that the code to
drop the connection when nothing cares about it is there in vanilla
4.2BSD, but is in the wrong place.  This fix moves it to the right
spot and mungs a conditional a little bit...

   The fix is to netinet/tcp_input.c; I think this is for vanilla
4.2, but your line numbers may vary.


*** Vanilla (??) 4.2 tcp_input.c	Fri Jan 24 12:24:00 1986
--- Fixed 4.2 tcp_input.c	Fri Jan 24 12:24:03 1986
***************
*** 358,363 ****
--- 358,372 ----
  			goto dropafterack;
  		if (ti->ti_len > 0) {
  			m_adj(m, ti->ti_len);
+   			/*
+  			 * If data is received on a connection after the
+  			 * user processes are gone, then RST the other end.
+  			 */
+  			if ((so->so_state & SS_NOFDREF) 
+  			    && tp->t_state > TCPS_CLOSE_WAIT) {
+  				tp = tcp_close(tp);
+  				goto dropwithreset;
+  			}
  			ti->ti_len = 0;
  			ti->ti_flags &= ~(TH_PUSH|TH_FIN);
  		}
***************
*** 404,419 ****
  			ti->ti_len -= todrop;
  			ti->ti_flags &= ~(TH_PUSH|TH_FIN);
  		}
- 	}
- 
- 	/*
- 	 * If data is received on a connection after the
- 	 * user processes are gone, then RST the other end.
- 	 */
- 	if ((so->so_state & SS_NOFDREF) && tp->t_state > TCPS_CLOSE_WAIT &&
- 	    ti->ti_len) {
- 		tp = tcp_close(tp);
- 		goto dropwithreset;
  	}
  
  	/*
--- 413,418 ----


-- 
Spoken: Steve Miller 	ARPA:	steve at mimsy.umd.edu	Phone: +1-301-454-4251
CSNet:	steve at umcp-cs 	UUCP:	{seismo,allegra}!umcp-cs!steve
USPS: Computer Science Dept., University of Maryland, College Park, MD 20742



More information about the Comp.sources.unix mailing list