ref: 4a09c1b22192e4e7a900daff1fd640bd90dff1da
parent: bf70626bc39f4e2cf8e318423de5eeaeeaa79af5
author: qwx <[email protected]>
date: Tue Aug 10 03:00:34 EDT 2021
sys: note handling better handling of crashes: kill all but affected proc, since they are more or less independent. mostly, this adds input and cd procs on the hit list. still have no idea how it is possible for two of the procs to get the note and call the handler at the same time (the second one is a uproc): ; pstree | grep xatrix 2844316 │ └games/q2xatrix +set game xatrix 2844324 │ └q2xatrix ; lstk 2844316 acid -l thread 2844316 /proc/2844316/text:amd64 plan 9 executable /sys/lib/acid/port /sys/lib/acid/amd64 /sys/lib/acid/thread acid: sleep(a0=0x3e8)+0xe /sys/src/libc/9syscall/sleep.s:6 lock(lk=0xdd1870)+0xaa /sys/src/libc/port/lock.c:25 i=0x2c99a9000003e8 threadxxxgrp(grp=0xffffffff00000003,dokill=0xaeaeaeae00000000)+0x2d /sys/src/libthread/kill.c:16 p=0xdd1870 t=0xaeaeaeaeaee61d3b threadintgrp()+0x11 /sys/src/libthread/kill.c:70 NET_Config()+0x17 /usr/qwx/p/qk2/udp.c:531 NET_Shutdown()+0xb /usr/qwx/p/qk2/udp.c:565 croak+0x37 /usr/qwx/p/qk2/sys.c:392 acid: echo kill > /proc/2844316/ctl ; lstk 2844324 acid -l thread 2844324 /proc/2844324/text:amd64 plan 9 executable /sys/lib/acid/port /sys/lib/acid/amd64 /sys/lib/acid/thread acid: sleep(a0=0x3e8)+0xe /sys/src/libc/9syscall/sleep.s:6 lock(lk=0x5fbb30)+0xaa /sys/src/libc/port/lock.c:25 i=0x2c998e000003e8 threadxxxgrp(grp=0x3,dokill=0x0)+0x12 /sys/src/libthread/kill.c:15 p=0x0 t=0x0 threadintgrp()+0x11 /sys/src/libthread/kill.c:70 NET_Config()+0x17 /usr/qwx/p/qk2/udp.c:531 NET_Shutdown()+0xb /usr/qwx/p/qk2/udp.c:565 croak+0x37 /usr/qwx/p/qk2/sys.c:392 acid: echo kill > /proc/2844324/ctl
--- a/cd.c
+++ b/cd.c
@@ -87,6 +87,9 @@
}
if(write(afd, buf, n) != n)
break;
+ /* threadkill requires that a libthread function be used
+ * somewhere: thread(2), errors notes and resources */
+ yield();
}
}
--- a/cl_main.c
+++ b/cl_main.c
@@ -1767,8 +1767,8 @@
CL_WriteConfiguration ();
+ IN_Shutdown ();
CDAudio_Shutdown ();
shutsnd();
- IN_Shutdown ();
R_Shutdown();
}
--- a/dat.h
+++ b/dat.h
@@ -1142,9 +1142,7 @@
NUMVERTEXNORMALS = 162,
/* thread groups */
- THin = 1,
- THsnd = 2,
- THnet = 3
+ THnet = 1,
};
extern FILE *log_stats_file;
--- a/in.c
+++ b/in.c
@@ -366,8 +366,6 @@
{
int t, ms, n, r;
- threadsetgrp(THin);
-
t = ms = 0;
for(;;){
sleep(1);
--- a/sys.c
+++ b/sys.c
@@ -381,13 +381,22 @@
return p;
}
+/* threadnotify does not allow handling sys: notes:
+ * /sys/src/libthread/note.c:93; most important is releasing the
+ * mouse, the rest is essentially killing all children as well
+ * as the parent (in case one of the other procs crashed);
+ * broken procs will remain afterwards, but not if threadexits
+ * et al is called. for threadkill to work, the proc must be
+ * using a libthread function (at least yield), otherwise it
+ * won't do diddly. too much could go wrong if going through
+ * all the shutdown functions. */
void
croak(void *, char *note)
{
if(!strncmp(note, "sys:", 4)){
IN_Grabm(0);
- shutsnd();
- NET_Shutdown();
+ threadkillgrp(THnet);
+ threadkillgrp(0);
}
noted(NDFLT);
}