socsvn commit: r290014 - soc2015/roam/ayiya_resp

roam at FreeBSD.org roam at FreeBSD.org
Fri Aug 21 15:42:41 UTC 2015


Author: roam
Date: Fri Aug 21 15:42:39 2015
New Revision: 290014
URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=290014

Log:
  Make ayiya_resp a bit less talkative.
  
  ObQuote:	"Silence is golden"

Modified:
  soc2015/roam/ayiya_resp/main.c

Modified: soc2015/roam/ayiya_resp/main.c
==============================================================================
--- soc2015/roam/ayiya_resp/main.c	Fri Aug 21 15:42:35 2015	(r290013)
+++ soc2015/roam/ayiya_resp/main.c	Fri Aug 21 15:42:39 2015	(r290014)
@@ -251,40 +251,32 @@
 	srandomdev();
 	STAILQ_INIT(&injectq);
 	time_t next_heartbeat = time(NULL);
-	time_t next_motd = next_heartbeat + 7 + (random() % 7);
+	time_t next_motd = next_heartbeat + 70 + (random() % 70);
 	static char inbuf[65536];
 	size_t inofs = 0;
 	for (;;) {
 		const time_t now = time(NULL);
-		debug("Loop: now %ld heartbeat %ld motd %ld\n",
-		    now, next_heartbeat, next_motd);
 		const bool do_heartbeat = !quiet && now >= next_heartbeat;
 		const bool do_motd = !quiet && now >= next_motd;
 		const bool do_inject = !STAILQ_EMPTY(&injectq);
-		debug("- select, heartbeat %s, motd %s, inject %s\n",
-		    do_heartbeat? "true": "false",
-		    do_motd? "true": "false",
-		    do_inject? "true": "false");
 		const unsigned sel = ayiya_select(ds, true,
 		    do_heartbeat || do_motd || do_inject);
-		if (sel == A_SEL_TIMEOUT) {
-			debug("- we got nothin'\n");
+		if (sel == A_SEL_TIMEOUT)
 			continue;
-		}
 		const time_t rcvat = time(NULL);
 
 		if (sel & A_SEL_WR_DATA) {
 			if (do_heartbeat) {
 				debug("Sending a heartbeat\n");
 				send_empty_packet(ds, AYIYA_OP_HEARTBEAT);
-				next_heartbeat = now + 10;
+				next_heartbeat = now + 100;
 			}
 
 			if (do_motd) {
 				debug("Sending a MOTD\n");
 				send_packet(ds, AYIYA_OP_MOTD,
 				    MOTD, sizeof(MOTD) - 1);
-				next_motd = now + 7 + (random() % 7);
+				next_motd = now + 70 + (random() % 70);
 			}
 
 			if (do_inject) {
@@ -302,12 +294,6 @@
 				warnx("Our Netgraph socket was closed");
 				return (0);
 			}
-			debug("Got %d bytes of data:\n", len);
-			for (int d = 0; d < len; d++)
-				debug("%02hhX%c", ng_msgbuf.buf[d],
-				    d % 16 == 15? '\n': ' ');
-			if (len % 16 != 0)
-				debug("\n");
 
 			const struct ng_ayiya_header * const hdr =
 			    (const struct ng_ayiya_header *)ng_msgbuf.buf;
@@ -343,7 +329,6 @@
 			debug("The listener's trying to tell us something!\n");
 			while (true) {
 				const ssize_t n = read(inputfd, inbuf + inofs, sizeof(inbuf) - inofs);
-				debug("- read() from the input stream returned %zd\n", n);
 				if (n == -1) {
 					if (errno == EAGAIN)
 						break;
@@ -353,25 +338,16 @@
 					break;
 				assert(n > 0);
 				inofs += (size_t)n;
-				debug("- for a total of %zu bytes in the buffer\n", inofs);
-				if (inofs >= sizeof(uint16_t))
-					debug("- AYIYA packet length: %u\n", *(const uint16_t *)inbuf);
-				else
-					debug("- not even two bytes of length received\n");
 
 				size_t bite;
 				while (bite = check_ayiya_packet(inbuf, inofs),
 				    bite > 0) {
-					debug("- we can bite off a %zu-byte packet\n", bite);
 					assert(bite <= inofs);
 					inject_ayiya_packet(inbuf, bite);
-					debug("- and now the queue is %sempty\n", STAILQ_EMPTY(&injectq)? "": "not ");
 					const size_t rest = inofs - bite;
 					bcopy(inbuf + bite, inbuf, rest);
 					inofs = rest;
-					debug("- left %zu bytes in the buffer\n", inofs);
 				}
-				debug("- no whole packet in the buffer\n");
 
 				if (inofs == sizeof(inbuf))
 					errx(1, "The listener is trying to send an AYIYA packet that won't fit in %zu bytes", sizeof(inbuf));


More information about the svn-soc-all mailing list