shithub: riscv

Download patch

ref: 72d08816abaa2935e8055d9cdfd73b59df5f9bd3
parent: bb2357de0cf04c6d8f41e7f7f72f1c033181d4e7
author: cinap_lenrek <cinap_lenrek@felloff.net>
date: Sat Oct 16 11:07:39 EDT 2021

devtls: implement "hangup" ctl message

This makes devtls connection directories compatible to
hangup function (see dial(2)).

--- a/sys/src/9/port/devtls.c
+++ b/sys/src/9/port/devtls.c
@@ -1751,10 +1751,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();
@@ -1767,6 +1767,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)