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

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