Blame SOURCES/libtirpc-0.2.4-nonblocking-mode.patch

b52932
commit a4fa582908b9c63957240cb0cb68b59d56244ef5
b52932
Author: Bodo Stroesser <bstroesser@ts.fujitsu.com>
b52932
Date:   Thu Nov 6 13:26:00 2014 -0500
b52932
b52932
    write_vc: fix write retry loop for nonblocking mode
b52932
    
b52932
    This is a simple fix for the write retry loop that is used on
b52932
    non-blocking connections if write() failed with -EAGAIN.
b52932
    
b52932
    Additionally it removes a redundant if () {}
b52932
    
b52932
    Erroneously at each cycle of the loop the length of the data
b52932
    to send is incremented and the buffer pointer is decremented.
b52932
    Thus, it might happen that:
b52932
    * the application crashes
b52932
    * data from the memory before the buffer is sent
b52932
    
b52932
    Signed-off-by: Bodo Stroesser <bstroesser@ts.fujitsu.com>
b52932
    Signed-off-by: Steve Dickson <steved@redhat.com>
b52932
b52932
diff --git a/src/svc_vc.c b/src/svc_vc.c
b52932
index 4c70de8..4d3ea51 100644
b52932
--- a/src/svc_vc.c
b52932
+++ b/src/svc_vc.c
b52932
@@ -559,20 +559,19 @@ write_vc(xprtp, buf, len)
b52932
 				cd->strm_stat = XPRT_DIED;
b52932
 				return (-1);
b52932
 			}
b52932
-			if (cd->nonblock && i != cnt) {
b52932
-				/*
b52932
-				 * For non-blocking connections, do not
b52932
-				 * take more than 2 seconds writing the
b52932
-				 * data out.
b52932
-				 *
b52932
-				 * XXX 2 is an arbitrary amount.
b52932
-				 */
b52932
-				gettimeofday(&tv1, NULL);
b52932
-				if (tv1.tv_sec - tv0.tv_sec >= 2) {
b52932
-					cd->strm_stat = XPRT_DIED;
b52932
-					return (-1);
b52932
-				}
b52932
+			/*
b52932
+			 * For non-blocking connections, do not
b52932
+			 * take more than 2 seconds writing the
b52932
+			 * data out.
b52932
+			 *
b52932
+			 * XXX 2 is an arbitrary amount.
b52932
+			 */
b52932
+			gettimeofday(&tv1, NULL);
b52932
+			if (tv1.tv_sec - tv0.tv_sec >= 2) {
b52932
+				cd->strm_stat = XPRT_DIED;
b52932
+				return (-1);
b52932
 			}
b52932
+			i = 0; /* Don't change buf and cnt */
b52932
 		}
b52932
 	}
b52932