From 1716b14104c94eb87b325c8e0ae73f29f7998816 Mon Sep 17 00:00:00 2001 From: Ronnie Sahlberg Date: Wed, 5 Jan 2022 07:44:18 +1000 Subject: [PATCH] Write PDUs straight to the wire when the queue is empty Signed-off-by: Ronnie Sahlberg --- include/libnfs-private.h | 2 ++ lib/pdu.c | 11 ++++++++--- lib/socket.c | 2 +- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/include/libnfs-private.h b/include/libnfs-private.h index c2dbfdb..b51fe0a 100644 --- a/include/libnfs-private.h +++ b/include/libnfs-private.h @@ -581,6 +581,8 @@ int nfs4_write_async(struct nfs_context *nfs, struct nfsfh *nfsfh, uint64_t count, const void *buf, nfs_cb cb, void *private_data); +int rpc_write_to_socket(struct rpc_context *rpc); + #ifdef __cplusplus } #endif diff --git a/lib/pdu.c b/lib/pdu.c index 6fa7552..a0d5525 100644 --- a/lib/pdu.c +++ b/lib/pdu.c @@ -296,11 +296,16 @@ int rpc_queue_pdu(struct rpc_context *rpc, struct rpc_pdu *pdu) #ifdef HAVE_MULTITHREADING nfs_mt_mutex_lock(&rpc->rpc_mutex); #endif /* HAVE_MULTITHREADING */ - rpc_enqueue(&rpc->outqueue, pdu); + rpc_enqueue(&rpc->outqueue, pdu); #ifdef HAVE_MULTITHREADING - nfs_mt_mutex_unlock(&rpc->rpc_mutex); + if (rpc->outqueue.head == pdu) { + nfs_mt_mutex_unlock(&rpc->rpc_mutex); + rpc_write_to_socket(rpc); + } else { + nfs_mt_mutex_unlock(&rpc->rpc_mutex); + } #endif /* HAVE_MULTITHREADING */ - + return 0; } diff --git a/lib/socket.c b/lib/socket.c index df54417..a5ed76c 100644 --- a/lib/socket.c +++ b/lib/socket.c @@ -226,7 +226,7 @@ rpc_which_events(struct rpc_context *rpc) return events; } -static int +int rpc_write_to_socket(struct rpc_context *rpc) { int32_t count;