Skip to content

Commit

Permalink
properly restart syscalls
Browse files Browse the repository at this point in the history
  • Loading branch information
Sascha Schumann committed Jul 1, 2003
1 parent 5e37b60 commit 4e81e8c
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions sapi/thttpd/thttpd.c
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ typedef struct {
int seen_cn;
} php_thttpd_globals;

#define PHP_SYS_CALL(x) do { x } while (n == -1 && errno == EINTR)

#ifdef PREMIUM_THTTPD
# define do_keep_alive persistent
#endif
Expand All @@ -73,7 +75,7 @@ static int sapi_thttpd_ub_write(const char *str, uint str_length TSRMLS_DC)
}

while (str_length > 0) {
n = send(TG(hc)->conn_fd, str, str_length, 0);
PHP_SYS_CALL(n = send(TG(hc)->conn_fd, str, str_length, 0););

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

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

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


TG(hc)->bytes_sent += n;
} else
} else {
n = 0;
}

if (n < len) {
int i;
Expand Down

0 comments on commit 4e81e8c

Please sign in to comment.