diff options
author | Trond Myklebust <Trond.Myklebust@netapp.com> | 2006-07-27 17:22:50 -0400 |
---|---|---|
committer | Trond Myklebust <Trond.Myklebust@netapp.com> | 2006-08-03 16:56:55 -0400 |
commit | e0ab53deaa91293a7958d63d5a2cf4c5645ad6f0 (patch) | |
tree | 1117ac18e263222ad91f3af90ddcaf65f37b79f6 /net/sunrpc/clnt.c | |
parent | f3d43c769d14b7065da7f62ec468b1fcb8cd6e06 (diff) |
RPC: Ensure that we disconnect TCP socket when client requests error out
If we're part way through transmitting a TCP request, and the client
errors, then we need to disconnect and reconnect the TCP socket in order to
avoid confusing the server.
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
(cherry picked from 031a50c8b9ea82616abd4a4e18021a25848941ce commit)
Diffstat (limited to 'net/sunrpc/clnt.c')
-rw-r--r-- | net/sunrpc/clnt.c | 52 |
1 files changed, 29 insertions, 23 deletions
diff --git a/net/sunrpc/clnt.c b/net/sunrpc/clnt.c index 4ba271f892c8..d6409e757219 100644 --- a/net/sunrpc/clnt.c +++ b/net/sunrpc/clnt.c | |||
@@ -921,26 +921,43 @@ call_transmit(struct rpc_task *task) | |||
921 | task->tk_status = xprt_prepare_transmit(task); | 921 | task->tk_status = xprt_prepare_transmit(task); |
922 | if (task->tk_status != 0) | 922 | if (task->tk_status != 0) |
923 | return; | 923 | return; |
924 | task->tk_action = call_transmit_status; | ||
924 | /* Encode here so that rpcsec_gss can use correct sequence number. */ | 925 | /* Encode here so that rpcsec_gss can use correct sequence number. */ |
925 | if (rpc_task_need_encode(task)) { | 926 | if (rpc_task_need_encode(task)) { |
926 | task->tk_rqstp->rq_bytes_sent = 0; | 927 | BUG_ON(task->tk_rqstp->rq_bytes_sent != 0); |
927 | call_encode(task); | 928 | call_encode(task); |
928 | /* Did the encode result in an error condition? */ | 929 | /* Did the encode result in an error condition? */ |
929 | if (task->tk_status != 0) | 930 | if (task->tk_status != 0) |
930 | goto out_nosend; | 931 | return; |
931 | } | 932 | } |
932 | task->tk_action = call_transmit_status; | ||
933 | xprt_transmit(task); | 933 | xprt_transmit(task); |
934 | if (task->tk_status < 0) | 934 | if (task->tk_status < 0) |
935 | return; | 935 | return; |
936 | if (!task->tk_msg.rpc_proc->p_decode) { | 936 | /* |
937 | task->tk_action = rpc_exit_task; | 937 | * On success, ensure that we call xprt_end_transmit() before sleeping |
938 | rpc_wake_up_task(task); | 938 | * in order to allow access to the socket to other RPC requests. |
939 | } | 939 | */ |
940 | return; | 940 | call_transmit_status(task); |
941 | out_nosend: | 941 | if (task->tk_msg.rpc_proc->p_decode != NULL) |
942 | /* release socket write lock before attempting to handle error */ | 942 | return; |
943 | xprt_abort_transmit(task); | 943 | task->tk_action = rpc_exit_task; |
944 | rpc_wake_up_task(task); | ||
945 | } | ||
946 | |||
947 | /* | ||
948 | * 5a. Handle cleanup after a transmission | ||
949 | */ | ||
950 | static void | ||
951 | call_transmit_status(struct rpc_task *task) | ||
952 | { | ||
953 | task->tk_action = call_status; | ||
954 | /* | ||
955 | * Special case: if we've been waiting on the socket's write_space() | ||
956 | * callback, then don't call xprt_end_transmit(). | ||
957 | */ | ||
958 | if (task->tk_status == -EAGAIN) | ||
959 | return; | ||
960 | xprt_end_transmit(task); | ||
944 | rpc_task_force_reencode(task); | 961 | rpc_task_force_reencode(task); |
945 | } | 962 | } |
946 | 963 | ||
@@ -992,18 +1009,7 @@ call_status(struct rpc_task *task) | |||
992 | } | 1009 | } |
993 | 1010 | ||
994 | /* | 1011 | /* |
995 | * 6a. Handle transmission errors. | 1012 | * 6a. Handle RPC timeout |
996 | */ | ||
997 | static void | ||
998 | call_transmit_status(struct rpc_task *task) | ||
999 | { | ||
1000 | if (task->tk_status != -EAGAIN) | ||
1001 | rpc_task_force_reencode(task); | ||
1002 | call_status(task); | ||
1003 | } | ||
1004 | |||
1005 | /* | ||
1006 | * 6b. Handle RPC timeout | ||
1007 | * We do not release the request slot, so we keep using the | 1013 | * We do not release the request slot, so we keep using the |
1008 | * same XID for all retransmits. | 1014 | * same XID for all retransmits. |
1009 | */ | 1015 | */ |