diff common-session.c @ 1191:b370b4b172d0

Fix ses.channel_signal_pending race
author Matt Johnston <matt@ucc.asn.au>
date Fri, 27 Nov 2015 21:26:43 +0800
parents a550e1e2e2a9
children 9169e4e7cbee
line wrap: on
line diff
--- a/common-session.c	Thu Nov 26 23:15:27 2015 +0800
+++ b/common-session.c	Fri Nov 27 21:26:43 2015 +0800
@@ -162,6 +162,7 @@
 		/* We get woken up when signal handlers write to this pipe.
 		   SIGCHLD in svr-chansession is the only one currently. */
 		FD_SET(ses.signal_pipe[0], &readfd);
+		ses.channel_signal_pending = 0;
 
 		/* set up for channels which can be read/written */
 		setchannelfds(&readfd, &writefd, writequeue_has_space);
@@ -211,7 +212,9 @@
 		wake up the select() above. */
 		if (FD_ISSET(ses.signal_pipe[0], &readfd)) {
 			char x;
+			TRACE(("signal pipe set"))
 			while (read(ses.signal_pipe[0], &x, 1) > 0) {}
+			ses.channel_signal_pending = 1;
 		}
 
 		/* check for auth timeout, rekeying required etc */