This is the mail archive of the ecos-patches@sourceware.org mailing list for the eCos project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Network TCP Handler: stale socket disposal


Hello -

This is my first post to this group; please correct me on netiquette and
appropriate usage as necessary. (For starters, should I have attached the
patch instead of cutting it into my text?)

I have been dealing with a situation in which certain TCP transactions
depleted the stock of network sockets allowed in our eCos configuration,
eventually disabling the product from opening either incoming or outgoing
network sockets. I believe the problem was due to the function 'sofree()'
in 'sys/kern/uipc_socket.c' preserving any socket flagged as SS_COMP,
whether or not it had also been flagged for reset. Adding a test of
so->so_error for the flags set by tcp_input() has resolved the issue.
Please examine and test the following patch and let me know if you see any
potentially troublesome side effects. Please apply the patch to eCos
sources if it seems to be appropriate.

Thanks.

John Mills
AirDefense, Inc.
Alpharetta, GA

++++++++++++++++++++++++++++ uipc_socket_c.pat +++++++++++++++++++++++++++++++

--- /opt/ecos/ecos-2.0/packages/net/bsd_tcpip/v2_0/src/sys/kern/uipc_socket.c	2003-02-12 10:29:52.000000000 -0500
+++ ./uipc_socket.c	2007-08-28 16:11:56.000000000 -0400
@@ -242,6 +246,11 @@
 			TAILQ_REMOVE(&head->so_incomp, so, so_list);
 			head->so_incqlen--;
 		} else if (so->so_state & SS_COMP) {
+			 if((so->so_error == ECONNRESET) ||
+				 (so->so_error == ECONNREFUSED)){ // forced drop if flagged
+				  TAILQ_REMOVE(&head->so_comp, so, so_list);
+				  head->so_qlen--;
+			 } else {
 			/*
 			 * We must not decommission a socket that's
 			 * on the accept(2) queue.  If we do, then
@@ -249,11 +258,13 @@
 			 * that the listening socket was ready.
 			 */
 			return;
+			 }
 		} else {
 			panic("sofree: not queued");
 		}
 		head->so_qlen--;
 		so->so_state &= ~SS_INCOMP;
+		so->so_state &= ~SS_COMP;
 		so->so_head = NULL;
 	}
 	sbrelease(&so->so_snd, so);

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++




Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]