diff common-session.c @ 925:bae0b34bc059 pam

Better PAM through recursion
author Matt Johnston <matt@ucc.asn.au>
date Wed, 12 Mar 2014 23:40:02 +0800
parents a1a97e98b0c1
children 73ea0dce9a57
line wrap: on
line diff
--- a/common-session.c	Sat Mar 08 21:00:57 2014 +0800
+++ b/common-session.c	Wed Mar 12 23:40:02 2014 +0800
@@ -125,14 +125,17 @@
 	TRACE(("leave session_init"))
 }
 
-void session_loop(void(*loophandler)()) {
+void session_loop() {
 
 	fd_set readfd, writefd;
 	struct timeval timeout;
 	int val;
 
+	assert(ses.recursion_count <= 1);
+	ses.recursion_count++;
+
 	/* main loop, select()s for all sockets in use */
-	for(;;) {
+	while (!ses.exit_recursion) {
 
 		timeout.tv_sec = select_timeout();
 		timeout.tv_usec = 0;
@@ -218,13 +221,13 @@
 		 * during rekeying ) */
 		channelio(&readfd, &writefd);
 
-		if (loophandler) {
-			loophandler();
+		if (ses.loop_handler) {
+			ses.loop_handler();
 		}
 
 	} /* for(;;) */
-	
-	/* Not reached */
+	ses.recursion_count--;
+	ses.exit_recursion = 0;
 }
 
 /* clean up a session on exit */