From bb8de9c26622fdbfed67bfcc78a5ee20e11d1687 Mon Sep 17 00:00:00 2001 From: Olga Kornievskaia Date: Fri, 27 May 2011 10:38:59 -0400 Subject: [PATCH] [libtirpc] catching network errors if during recv we received an error, then propagate that to the caller. otherwise, do time out check. also do timeout check if the thread's xid didn't match received xid (making sure we'll timeout if we have a starving thread that will never receive a reply) --- daemon/nfs41_rpc.c | 4 ++-- libtirpc/src/clnt_vc.c | 27 +++++++++++++++++---------- 2 files changed, 19 insertions(+), 12 deletions(-) diff --git a/daemon/nfs41_rpc.c b/daemon/nfs41_rpc.c index db85e1a..d6e1f4c 100644 --- a/daemon/nfs41_rpc.c +++ b/daemon/nfs41_rpc.c @@ -34,7 +34,7 @@ static enum clnt_stat send_null(CLIENT *client) { - struct timeval timeout = {10, 0}; + struct timeval timeout = {10, 100}; return clnt_call(client, 0, (xdrproc_t)xdr_void, NULL, @@ -337,7 +337,7 @@ int nfs41_send_compound( IN char *inbuf, OUT char *outbuf) { - struct timeval timeout = {90, 0}; + struct timeval timeout = {90, 100}; enum clnt_stat rpc_status; int status, count = 0, one = 1, zero = 0; uint32_t version; diff --git a/libtirpc/src/clnt_vc.c b/libtirpc/src/clnt_vc.c index 1e882bf..5cb7be6 100644 --- a/libtirpc/src/clnt_vc.c +++ b/libtirpc/src/clnt_vc.c @@ -582,17 +582,20 @@ call_again: ct->reply_msg.acpted_rply.ar_results.proc = (xdrproc_t)xdr_void; if (!ct->use_stored_reply_msg) { if (!xdrrec_skiprecord(xdrs)) { + if (ct->ct_error.re_status != RPC_CANTRECV) { + time(&time_now); + if (time_now - start_send >= timeout.tv_sec) { + ct->ct_error.re_status = RPC_TIMEDOUT; + goto out; + } #ifdef NO_CB_4_KRB5P - if (cl->cb_thread != INVALID_HANDLE_VALUE) + if (cl->cb_thread != INVALID_HANDLE_VALUE) #endif - release_fd_lock(ct->ct_fd, mask); - time(&time_now); - if (time_now - start_send >= timeout.tv_sec) { - ct->ct_error.re_status = RPC_TIMEDOUT; - goto out; + release_fd_lock(ct->ct_fd, mask); + SwitchToThread(); + continue; } - SwitchToThread(); - continue; + goto out; } if (!xdr_getxiddir(xdrs, &ct->reply_msg)) { if (ct->ct_error.re_status == RPC_SUCCESS) { @@ -621,6 +624,11 @@ call_again: break; } else { + time(&time_now); + if (time_now - start_send >= timeout.tv_sec) { + ct->ct_error.re_status = RPC_TIMEDOUT; + goto out; + } ct->use_stored_reply_msg = TRUE; release_fd_lock(ct->ct_fd, mask); SwitchToThread(); @@ -930,8 +938,7 @@ read_vc(ctp, buf, len) */ struct ct_data *ct = (struct ct_data *)ctp; struct pollfd fd; - int milliseconds = (int)((ct->ct_wait.tv_sec * 1000) + - (ct->ct_wait.tv_usec / 1000)); + int milliseconds = ct->ct_wait.tv_usec; if (len == 0) return (0);