git: 9front

Download patch

ref: a3fb3fb3df5e7898b5bfe141ddd76417bd50075a
parent: e2c7dcbddd2b01143b698513cc34c0fb39101130
author: Jacob Moody <moody@posixcafe.org>
date: Tue Oct 18 23:00:04 EDT 2022

rio: prevent some more keyboard lockups

Triggered these from ktrans a couple times when poking at it, the
issue is that we get stuck wanting to emit to the tap without a valid
listener.  This ensures we are never stuch sending to a deleted window
or dead tap user.

--- a/sys/src/cmd/rio/rio.c
+++ b/sys/src/cmd/rio/rio.c
@@ -389,6 +389,7 @@
 keyboardtap(void*)
 {
 	char *s, *ctl;
+	char *e;
 	char *watched;
 	Window *w, *cur;
 
@@ -414,7 +415,7 @@
 			if(cur != nil){
 				alts[Ainp].c = cur->ck;
 				if(tapseats[OREAD] == Tapoff)	
-					break;
+					goto Reset;
 				if(alts[Awatch].op == CHANSND)
 					free(watched);
 				watched = smprint("%c%d", Tapfocus, cur->id);
@@ -424,9 +425,14 @@
 				free(s);
 			goto Reset;
 		case Actl:
-			sendp(resptap, tapctlmsg(ctl));
+			e = tapctlmsg(ctl);
+			sendp(resptap, e);
+			if(e != nil || *ctl != Tapoff){
+				free(ctl);
+				break;
+			}
 			free(ctl);
-			break;
+			goto Reset;
 		case Afrom:
 			if(cur == nil){
 				free(s);
--