summaryrefslogtreecommitdiffstats
path: root/sys/nfs/nfs_socket.c
diff options
context:
space:
mode:
authormpi <mpi@openbsd.org>2020-01-15 13:17:35 +0000
committermpi <mpi@openbsd.org>2020-01-15 13:17:35 +0000
commit1a273344ae32a61ecc379c236ac9b23f6623257d (patch)
tree201d8a36fd06adb8433e2bc350fcaf6edbd86899 /sys/nfs/nfs_socket.c
parentAdd automated certificate generation, psk and certificate authentication (diff)
downloadwireguard-openbsd-1a273344ae32a61ecc379c236ac9b23f6623257d.tar.xz
wireguard-openbsd-1a273344ae32a61ecc379c236ac9b23f6623257d.zip
Keep socket timeout intervals in nsecs and use them with tsleep_nsec(9).
Introduce and use TIMEVAL_TO_NSEC() to convert SO_RCVTIMEO/SO_SNDTIMEO specified values into nanoseconds. As a side effect it is now possible to specify a timeout larger that (USHRT_MAX / 100) seconds. To keep code simple `so_linger' now represents a number of seconds with 0 meaning no timeout or 'infinity'. Yes, the 0 -> INFSLP API change makes conversions complicated as many timeout holders are still memset()'d. Inputs from cheloha@ and bluhm@, ok bluhm@
Diffstat (limited to 'sys/nfs/nfs_socket.c')
-rw-r--r--sys/nfs/nfs_socket.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/sys/nfs/nfs_socket.c b/sys/nfs/nfs_socket.c
index 54d6e2a0d36..7648f35efff 100644
--- a/sys/nfs/nfs_socket.c
+++ b/sys/nfs/nfs_socket.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: nfs_socket.c,v 1.134 2019/12/05 10:41:57 mpi Exp $ */
+/* $OpenBSD: nfs_socket.c,v 1.135 2020/01/15 13:17:35 mpi Exp $ */
/* $NetBSD: nfs_socket.c,v 1.27 1996/04/15 20:20:00 thorpej Exp $ */
/*
@@ -315,7 +315,8 @@ nfs_connect(struct nfsmount *nmp, struct nfsreq *rep)
* that interruptible mounts don't hang here for a long time.
*/
while ((so->so_state & SS_ISCONNECTING) && so->so_error == 0) {
- sosleep(so, &so->so_timeo, PSOCK, "nfscon", 2 * hz);
+ sosleep_nsec(so, &so->so_timeo, PSOCK, "nfscon",
+ SEC_TO_NSEC(2));
if ((so->so_state & SS_ISCONNECTING) &&
so->so_error == 0 && rep &&
(error = nfs_sigintr(nmp, rep, rep->r_procp)) != 0){
@@ -333,11 +334,11 @@ nfs_connect(struct nfsmount *nmp, struct nfsreq *rep)
* Always set receive timeout to detect server crash and reconnect.
* Otherwise, we can get stuck in soreceive forever.
*/
- so->so_rcv.sb_timeo = (5 * hz);
+ so->so_rcv.sb_timeo_nsecs = SEC_TO_NSEC(5);
if (nmp->nm_flag & (NFSMNT_SOFT | NFSMNT_INT))
- so->so_snd.sb_timeo = (5 * hz);
+ so->so_snd.sb_timeo_nsecs = SEC_TO_NSEC(5);
else
- so->so_snd.sb_timeo = 0;
+ so->so_snd.sb_timeo_nsecs = INFSLP;
if (nmp->nm_sotype == SOCK_DGRAM) {
sndreserve = nmp->nm_wsize + NFS_MAXPKTHDR;
rcvreserve = (max(nmp->nm_rsize, nmp->nm_readdirsize) +