X-Git-Url: http://git.vrable.net/?a=blobdiff_plain;f=nfs3%2Frpc.c;h=2342b79d514ad9b864040f8617aa590f09c4d857;hb=9b6731def3f83aa92e4214fb610d6c41cae1a88a;hp=76de1cd86663ddb2bc3a922ec2abc93d0db2f464;hpb=fb15c75f3c8eeb3d7b277795ced44bb4928273a1;p=bluesky.git diff --git a/nfs3/rpc.c b/nfs3/rpc.c index 76de1cd..2342b79 100644 --- a/nfs3/rpc.c +++ b/nfs3/rpc.c @@ -27,6 +27,8 @@ #include "bluesky.h" extern BlueSkyFS *fs; +static int outstanding_rpcs = 0; + /* TCP port number to use for NFS protocol. (Should be 2049.) */ #define NFS_SERVICE_PORT 2051 @@ -128,6 +130,8 @@ async_rpc_send_failure(RPCRequest *req, enum accept_stat stat) { struct rpc_fail_reply header; + g_atomic_int_add(&outstanding_rpcs, -1); + header.xid = htonl(req->xid); header.type = htonl(1); /* REPLY */ header.stat = htonl(MSG_ACCEPTED); @@ -189,6 +193,8 @@ async_rpc_send_reply(RPCRequest *req, void *result) return; } + g_atomic_int_add(&outstanding_rpcs, -1); + struct rpc_reply header; header.xid = htonl(req->xid); header.type = htonl(1); /* REPLY */ @@ -210,8 +216,10 @@ async_rpc_send_reply(RPCRequest *req, void *result) time_end = bluesky_now_hires(); +#if 0 printf("RPC[%"PRIx32"]: time = %"PRId64" ns\n", req->xid, time_end - req->time_start); +#endif /* Clean up. */ g_string_free(str, TRUE); @@ -307,12 +315,14 @@ nfs_program_3(RPCRequest *req) xdrproc_t _xdr_argument, _xdr_result; char *(*local)(char *, RPCRequest *); +#if 0 if (req->req_proc < sizeof(nfs_proc_names) / sizeof(const char *)) { printf("Dispatched NFS RPC message type %s\n", nfs_proc_names[req->req_proc]); } else { printf("Dispatched unknown NFS RPC message type %d\n", req->req_proc); } +#endif switch (req->req_proc) { case NFSPROC3_NULL: @@ -489,6 +499,13 @@ static void sig_handler(int sig) static gboolean async_flushd(gpointer data) { +#if 0 + int rpc_count = g_atomic_int_get(&outstanding_rpcs); + if (rpc_count != 0) { + g_print("Currently outstanding RPC requests: %d\n", rpc_count); + } +#endif + if (fs_dump_requested) { bluesky_debug_dump(fs); fs_dump_requested = 0; @@ -568,6 +585,8 @@ static gboolean async_rpc_dispatch(RPCConnection *rpc) return FALSE; } + g_atomic_int_add(&outstanding_rpcs, 1); + RPCRequest *req = g_new0(RPCRequest, 1); req->connection = rpc; req->time_start = time_start; @@ -588,18 +607,24 @@ static gboolean async_rpc_dispatch(RPCConnection *rpc) buf += sizeof(struct rpc_call_header); for (i = 0; i < 2; i++) { struct rpc_auth *auth = (struct rpc_auth *)buf; - if (buf - msg->str + sizeof(struct rpc_auth) > msg->len) + if (buf - msg->str + sizeof(struct rpc_auth) > msg->len) { + g_atomic_int_add(&outstanding_rpcs, -1); return FALSE; + } gsize authsize = ntohl(auth->len) + sizeof(struct rpc_auth); - if (authsize > MAX_RPC_MSGSIZE) + if (authsize > MAX_RPC_MSGSIZE) { + g_atomic_int_add(&outstanding_rpcs, -1); return FALSE; + } buf += authsize; } - if (buf - msg->str > msg->len) + if (buf - msg->str > msg->len) { + g_atomic_int_add(&outstanding_rpcs, -1); return FALSE; + } req->raw_args = msg; req->raw_args_header_bytes = buf - msg->str;