[master] 97b61252d v1l: Preserve a copy of errno after writev(2)

Dridi Boukelmoune dridi.boukelmoune at gmail.com
Fri Jun 9 10:08:11 UTC 2023


commit 97b61252dba824545c5acb717ab54692ecd5b333
Author: Dridi Boukelmoune <dridi.boukelmoune at gmail.com>
Date:   Fri Jun 9 11:45:01 2023 +0200

    v1l: Preserve a copy of errno after writev(2)
    
    This is to ensure we don't lose write errors by the time we make the
    final checks.

diff --git a/bin/varnishd/http1/cache_http1_line.c b/bin/varnishd/http1/cache_http1_line.c
index 544f80d8f..db5ca93c5 100644
--- a/bin/varnishd/http1/cache_http1_line.c
+++ b/bin/varnishd/http1/cache_http1_line.c
@@ -174,6 +174,7 @@ stream_close_t
 V1L_Flush(const struct worker *wrk)
 {
 	ssize_t i;
+	int err;
 	struct v1l *v1l;
 	char cbuf[32];
 
@@ -228,7 +229,9 @@ V1L_Flush(const struct worker *wrk)
 			 * prevent slowloris attacks
 			 */
 
-			if (errno == EWOULDBLOCK) {
+			err = errno;
+
+			if (err == EWOULDBLOCK) {
 				VSLb(v1l->vsl, SLT_Debug,
 				    "Hit idle send timeout, "
 				    "wrote = %zd/%zd; retrying",
@@ -237,14 +240,14 @@ V1L_Flush(const struct worker *wrk)
 
 			if (i > 0)
 				v1l_prune(v1l, i);
-		} while (i > 0 || errno == EWOULDBLOCK);
+		} while (i > 0 || err == EWOULDBLOCK);
 
 		if (i <= 0) {
 			VSLb(v1l->vsl, SLT_Debug,
 			    "Write error, retval = %zd, len = %zd, errno = %s",
-			    i, v1l->liov, VAS_errtxt(errno));
+			    i, v1l->liov, VAS_errtxt(err));
 			assert(v1l->werr == SC_NULL);
-			if (errno == EPIPE)
+			if (err == EPIPE)
 				v1l->werr = SC_REM_CLOSE;
 			else
 				v1l->werr = SC_TX_ERROR;


More information about the varnish-commit mailing list