shithub: drawterm

Download patch

ref: e9853213c893b23d880e0a2dfba7c7f7de436889
parent: e65af5d4e422db4722e2cc026ecca5607dedfc5a
author: cinap_lenrek <[email protected]>
date: Sat Oct 16 11:13:01 EDT 2021

devtls: implement "hangup" control message

--- a/kern/devtls.c
+++ b/kern/devtls.c
@@ -1749,10 +1749,10 @@
 	}else if(strcmp(cb->f[0], "alert") == 0){
 		if(cb->nf != 2)
 			error("usage: alert n");
+		m = strtol(cb->f[1], nil, 0);
+	Hangup:
 		if(tr->c == nil)
 			error("must set fd before sending alerts");
-		m = strtol(cb->f[1], nil, 0);
-
 		qunlock(&tr->in.seclock);
 		qunlock(&tr->out.seclock);
 		poperror();
@@ -1765,6 +1765,9 @@
 			tlsclosed(tr, SLClose);
 
 		return n;
+	} else if(strcmp(cb->f[0], "hangup") == 0){
+		m = ECloseNotify;
+		goto Hangup;
 	} else if(strcmp(cb->f[0], "debug") == 0){
 		if(cb->nf == 2){
 			if(strcmp(cb->f[1], "on") == 0)