Skip to content

Commit 4e81e8c

Browse files
author
Sascha Schumann
committed
properly restart syscalls
1 parent 5e37b60 commit 4e81e8c

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

sapi/thttpd/thttpd.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@ typedef struct {
5050
int seen_cn;
5151
} php_thttpd_globals;
5252

53+
#define PHP_SYS_CALL(x) do { x } while (n == -1 && errno == EINTR)
54+
5355
#ifdef PREMIUM_THTTPD
5456
# define do_keep_alive persistent
5557
#endif
@@ -73,7 +75,7 @@ static int sapi_thttpd_ub_write(const char *str, uint str_length TSRMLS_DC)
7375
}
7476

7577
while (str_length > 0) {
76-
n = send(TG(hc)->conn_fd, str, str_length, 0);
78+
PHP_SYS_CALL(n = send(TG(hc)->conn_fd, str, str_length, 0););
7779

7880
if (n == -1) {
7981
if (errno == EAGAIN) {
@@ -108,7 +110,7 @@ static int do_writev(struct iovec *vec, int nvec, int len TSRMLS_DC)
108110
assert(nvec <= IOV_MAX);
109111

110112
if (TG(sbuf).c == 0) {
111-
n = writev(TG(hc)->conn_fd, vec, nvec);
113+
PHP_SYS_CALL(n = writev(TG(hc)->conn_fd, vec, nvec););
112114

113115
if (n == -1) {
114116
if (errno == EAGAIN) {
@@ -120,8 +122,9 @@ static int do_writev(struct iovec *vec, int nvec, int len TSRMLS_DC)
120122

121123

122124
TG(hc)->bytes_sent += n;
123-
} else
125+
} else {
124126
n = 0;
127+
}
125128

126129
if (n < len) {
127130
int i;

0 commit comments

Comments
 (0)