summaryrefslogtreecommitdiffstats
path: root/sys/nfs/nfs_common.c
diff options
context:
space:
mode:
authorps <ps@FreeBSD.org>2004-12-06 17:33:52 +0000
committerps <ps@FreeBSD.org>2004-12-06 17:33:52 +0000
commit5feadd3eba463ffad1e8b8e55a5ff30c5ccc861a (patch)
tree534a6e09b19a42319606629ce43460d95a24d8ef /sys/nfs/nfs_common.c
parente196d800834b17b34ab2b098462739d2da4b3a24 (diff)
downloadFreeBSD-src-5feadd3eba463ffad1e8b8e55a5ff30c5ccc861a.zip
FreeBSD-src-5feadd3eba463ffad1e8b8e55a5ff30c5ccc861a.tar.gz
Add non-blocking versions of nfsm_dissect() and friends, for use from
socket callbacks or similar callers, from both the NFS client and the server. Instituted nfsm_dissect_nonblock(), nfsm_dissect_xx_nonblock(). And nfsm_disct() now takes an extra M_TRYWAIT/M_DONTWAIT argument. Submitted by: Mohan Srinivasan mohans at yahoo-inc dot com
Diffstat (limited to 'sys/nfs/nfs_common.c')
-rw-r--r--sys/nfs/nfs_common.c22
1 files changed, 19 insertions, 3 deletions
diff --git a/sys/nfs/nfs_common.c b/sys/nfs/nfs_common.c
index 019918d..6c66a39 100644
--- a/sys/nfs/nfs_common.c
+++ b/sys/nfs/nfs_common.c
@@ -76,6 +76,8 @@ nfstype nfsv3_type[9] = {
NFNON, NFREG, NFDIR, NFBLK, NFCHR, NFLNK, NFSOCK, NFFIFO, NFNON
};
+static void *nfsm_dissect_xx_sub(int s, struct mbuf **md, caddr_t *dpos, int how);
+
u_quad_t
nfs_curusec(void)
{
@@ -164,7 +166,7 @@ nfsm_mbuftouio(struct mbuf **mrep, struct uio *uiop, int siz, caddr_t *dpos)
* cases. (The macros use the vars. dpos and dpos2)
*/
void *
-nfsm_disct(struct mbuf **mdp, caddr_t *dposp, int siz, int left)
+nfsm_disct(struct mbuf **mdp, caddr_t *dposp, int siz, int left, int how)
{
struct mbuf *mp, *mp2;
int siz2, xfer;
@@ -187,7 +189,9 @@ nfsm_disct(struct mbuf **mdp, caddr_t *dposp, int siz, int left)
} else if (siz > MHLEN) {
panic("nfs S too big");
} else {
- MGET(mp2, M_TRYWAIT, MT_DATA);
+ MGET(mp2, how, MT_DATA);
+ if (mp2 == NULL)
+ return NULL;
mp2->m_next = mp->m_next;
mp->m_next = mp2;
mp->m_len -= left;
@@ -267,6 +271,18 @@ nfsm_build_xx(int s, struct mbuf **mb, caddr_t *bpos)
void *
nfsm_dissect_xx(int s, struct mbuf **md, caddr_t *dpos)
{
+ return nfsm_dissect_xx_sub(s, md, dpos, M_TRYWAIT);
+}
+
+void *
+nfsm_dissect_xx_nonblock(int s, struct mbuf **md, caddr_t *dpos)
+{
+ return nfsm_dissect_xx_sub(s, md, dpos, M_DONTWAIT);
+}
+
+static void *
+nfsm_dissect_xx_sub(int s, struct mbuf **md, caddr_t *dpos, int how)
+{
int t1;
char *cp2;
void *ret;
@@ -277,7 +293,7 @@ nfsm_dissect_xx(int s, struct mbuf **md, caddr_t *dpos)
*dpos += s;
return ret;
}
- cp2 = nfsm_disct(md, dpos, s, t1);
+ cp2 = nfsm_disct(md, dpos, s, t1, how);
return cp2;
}
OpenPOWER on IntegriCloud