From: Ronnie Sahlberg Date: Sun, 11 Sep 2011 11:32:48 +0000 (+1000) Subject: Add a call to find the queue-length so we can see how many I/O we have in flight... X-Git-Tag: upstream/1.9.6^2~307 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=83aa785d927875e69ca4afd58fb53ffc84f24413;p=deb_libnfs.git Add a call to find the queue-length so we can see how many I/O we have in flight from the application layer. --- diff --git a/include/libnfs-raw.h b/include/libnfs-raw.h index 573205c..bc71133 100644 --- a/include/libnfs-raw.h +++ b/include/libnfs-raw.h @@ -37,6 +37,7 @@ int rpc_get_fd(struct rpc_context *rpc); int rpc_which_events(struct rpc_context *rpc); int rpc_service(struct rpc_context *rpc, int revents); char *rpc_get_error(struct rpc_context *rpc); +int rpc_queue_length(struct rpc_context *rpc); #define RPC_STATUS_SUCCESS 0 diff --git a/include/libnfs.h b/include/libnfs.h index dd63f96..3ff49d7 100644 --- a/include/libnfs.h +++ b/include/libnfs.h @@ -57,6 +57,7 @@ struct utimbuf { EXTERN int nfs_get_fd(struct nfs_context *nfs); EXTERN int nfs_which_events(struct nfs_context *nfs); EXTERN int nfs_service(struct nfs_context *nfs, int revents); +EXTERN int nfs_queue_length(struct nfs_context *nfs); /* * Used if you need different credentials than the default for the current user. diff --git a/lib/libnfs.c b/lib/libnfs.c index 1f64bd0..8c408b2 100644 --- a/lib/libnfs.c +++ b/lib/libnfs.c @@ -121,6 +121,11 @@ int nfs_get_fd(struct nfs_context *nfs) return rpc_get_fd(nfs->rpc); } +int nfs_queue_length(struct nfs_context *nfs) +{ + return rpc_queue_length(nfs->rpc); +} + int nfs_which_events(struct nfs_context *nfs) { return rpc_which_events(nfs->rpc); diff --git a/lib/socket.c b/lib/socket.c index 760da2f..d93acd8 100644 --- a/lib/socket.c +++ b/lib/socket.c @@ -315,7 +315,7 @@ int rpc_service(struct rpc_context *rpc, int revents) if (revents & POLLIN) { if (rpc_read_from_socket(rpc) != 0) { - rpc_disconnect_requeue(rpc); + rpc_disconnect_requeue(rpc); return 0; } } @@ -514,3 +514,17 @@ struct sockaddr *rpc_get_recv_sockaddr(struct rpc_context *rpc) { return (struct sockaddr *)&rpc->udp_src; } + +int rpc_queue_length(struct rpc_context *rpc) +{ + int i=0; + struct rpc_pdu *pdu; + + for(pdu = rpc->outqueue; pdu; pdu = pdu->next) { + i++; + } + for(pdu = rpc->waitpdu; pdu; pdu = pdu->next) { + i++; + } + return i; +}