shithub: orca

Download patch

ref: 986cf6b8ab96c2954d78cfdd411cf39f8d4cf77a
parent: 054c066680b24a99a56b232a32edfe9c3484f734
author: Sigrid Haflínudóttir <ftrvxmtrx@gmail.com>
date: Sat Feb 22 06:40:42 EST 2020

plan9: udp: move reopening to netdial()

--- a/plan9.c
+++ b/plan9.c
@@ -249,10 +249,25 @@
 }
 
 static void
+midiopen(void)
+{
+	if (midi >= 0) {
+		close(midi);
+		midi = -1;
+	}
+	if (midi < 0 && (midi = open(midipath, OWRITE)) < 0) {
+		fprint(2, "midi failed: %r\n");
+		/* FIXME display error */
+	}
+}
+
+static void
 netdial(void)
 {
-	if (udp >= 0)
+	if (udp >= 0) {
 		close(udp);
+		udp = -1;
+	}
 	if (udp < 0 && (udp = dial(netmkaddr(ip, "udp", udpport), nil, nil, nil)) < 0) {
 		fprint(2, "udp failed: %r\n");
 		/* FIXME display error */
@@ -308,8 +323,6 @@
 		else if (strcmp(s, "ip") == 0) {
 			free(ip);
 			ip = strdup(a);
-			close(udp);
-			udp = -1;
 			netdial();
 		}