code: plan9front

Download patch

ref: 2cd313668cea156fd13b54873d7934d9b15d8081
parent: 676f990fbbe3bb4e245a79ce665fdf9f55ffd3cc
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);