--- lighttpd-1.4.19/src/mod_cgi.c 2008-02-28 21:19:24.000000000 +0000 +++ lighttpd-1.4.19.patched/src/mod_cgi.c 2008-04-15 05:06:05.335717999 +0000 @@ -1022,7 +1022,8 @@ /* there is content to send */ for (c = cq->first; c; c = cq->first) { int r = 0; - + int write_eintr = 0; + /* copy all chunks */ switch(c->type) { case FILE_CHUNK: @@ -1058,7 +1059,9 @@ switch(errno) { case ENOSPC: con->http_status = 507; - + break; + case EINTR: + write_eintr = 1; break; default: con->http_status = 403; @@ -1071,7 +1074,9 @@ switch(errno) { case ENOSPC: con->http_status = 507; - + break; + case EINTR: + write_eintr = 1; break; default: con->http_status = 403; @@ -1086,7 +1091,16 @@ if (r > 0) { c->offset += r; cq->bytes_out += r; - } else { + } + if (r < 0) { + /* if write failed for reasons other than EINTR log and break out */ + if (write_eintr != 1) { + log_error_write(srv, __FILE__, __LINE__, "ss", "write() failed due to: ", strerror(errno)); + con->http_status = 500; + break; + } + } + if (r == 0) { break; } chunkqueue_remove_finished_chunks(cq);