Convert the two pseudo-drivers to use tsleep_nsec(9) in their read(2)
routine, both drivers block indefinitely.
ok?
Index: net/if_tun.c
===================================================================
RCS file: /cvs/src/sys/net/if_tun.c,v
retrieving revision 1.190
diff -u -p -r1.190 if_tun.c
--- net/if_tun.c 13 Sep 2019 01:31:24 -0000 1.190
+++ net/if_tun.c 7 Oct 2019 12:49:04 -0000
@@ -751,8 +751,8 @@ tun_dev_read(struct tun_softc *tp, struc
int destroyed;
while ((tp->tun_flags & TUN_READY) != TUN_READY) {
- if ((error = tsleep((caddr_t)tp,
- (PZERO + 1)|PCATCH, "tunread", 0)) != 0)
+ if ((error = tsleep_nsec(tp,
+ (PZERO + 1)|PCATCH, "tunread", INFSLP)) != 0)
return (error);
/* Make sure the interface still exists. */
ifp1 = if_get(ifidx);
@@ -766,8 +766,8 @@ tun_dev_read(struct tun_softc *tp, struc
if (tp->tun_flags & TUN_NBIO && ioflag & IO_NDELAY)
return (EWOULDBLOCK);
tp->tun_flags |= TUN_RWAIT;
- if ((error = tsleep((caddr_t)tp,
- (PZERO + 1)|PCATCH, "tunread", 0)) != 0)
+ if ((error = tsleep_nsec(tp,
+ (PZERO + 1)|PCATCH, "tunread", INFSLP)) != 0)
return (error);
/* Make sure the interface still exists. */
ifp1 = if_get(ifidx);
Index: net/switchctl.c
===================================================================
RCS file: /cvs/src/sys/net/switchctl.c,v
retrieving revision 1.15
diff -u -p -r1.15 switchctl.c
--- net/switchctl.c 12 May 2019 16:38:02 -0000 1.15
+++ net/switchctl.c 7 Oct 2019 12:49:17 -0000
@@ -148,7 +148,7 @@ switchread(dev_t dev, struct uio *uio, i
goto failed;
}
sc->sc_swdev->swdev_waiting = 1;
- error = tsleep(sc, (PZERO + 1)|PCATCH, "switchread", 0);
+ error = tsleep_nsec(sc, (PZERO + 1)|PCATCH, "switchread",
INFSLP);
if (error != 0)
goto failed;
/* sc might be deleted while sleeping */