Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 21 Aug 2015 16:19:35 GMT
From:      roam@FreeBSD.org
To:        svn-soc-all@FreeBSD.org
Subject:   socsvn commit: r290031 - soc2015/roam/ayiya_resp
Message-ID:  <201508211619.t7LGJZSD044731@socsvn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: roam
Date: Fri Aug 21 16:19:35 2015
New Revision: 290031
URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=290031

Log:
  ayiya_resp: handle losing the listener.
  
  When a tunnel is reestablished with a different peer, ayiya_listen
  will close the socket to the currently running ayiya_resp process;
  deal with this gracefully and exit instead of outputting a barrage
  of incorrect diagnostic messages until ayiya_listen kills it.
  
  ObQuote:	"It's so funny how we don't talk anymore"

Modified:
  soc2015/roam/ayiya_resp/main.c

Modified: soc2015/roam/ayiya_resp/main.c
==============================================================================
--- soc2015/roam/ayiya_resp/main.c	Fri Aug 21 16:18:53 2015	(r290030)
+++ soc2015/roam/ayiya_resp/main.c	Fri Aug 21 16:19:35 2015	(r290031)
@@ -328,6 +328,7 @@
 
 		if (sel & A_SEL_RD_INPUT) {
 			debug("The listener's trying to tell us something!\n");
+			bool got_data = false;
 			while (true) {
 				const ssize_t n = read(inputfd, inbuf + inofs, sizeof(inbuf) - inofs);
 				if (n == -1) {
@@ -335,9 +336,14 @@
 						break;
 					err(1, "Could not read from the listener input channel");
 				}
-				if (n == 0)
-					break;
+				if (n == 0) {
+					if (got_data)
+						break;
+					warnx("The listener closed the socket, giving up");
+					exit(0);
+				}
 				assert(n > 0);
+				got_data = true;
 				inofs += (size_t)n;
 
 				size_t bite;



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