BUG/MINOR: connection: check EINTR when sending a PROXY header
PROXY protocol header was not tolerant to signals, so it might cause a
connection to report an error if a signal comes in at the exact same
moment the send is done.
This is 1.5-specific and does not need any backport.
diff --git a/src/connection.c b/src/connection.c
index b477b46..78d28ed 100644
--- a/src/connection.c
+++ b/src/connection.c
@@ -563,16 +563,20 @@
/* we have to send the whole trash. If the data layer has a
* pending write, we'll also set MSG_MORE.
*/
- ret = send(conn->t.sock.fd, trash.str, trash.len, (conn->flags & CO_FL_DATA_WR_ENA) ? MSG_MORE : 0);
+ do {
+ ret = send(conn->t.sock.fd, trash.str, trash.len, (conn->flags & CO_FL_DATA_WR_ENA) ? MSG_MORE : 0);
- if (ret == 0)
- goto out_wait;
-
- if (ret < 0) {
- if (errno == EAGAIN || errno == ENOTCONN)
+ if (ret == 0)
goto out_wait;
- goto out_error;
- }
+
+ if (ret < 0) {
+ if (errno == EAGAIN || errno == ENOTCONN)
+ goto out_wait;
+ if (errno == EINTR)
+ continue;
+ goto out_error;
+ }
+ } while (0);
if (ret != trash.len)
goto out_error;