Handled EINTR from write() and pwrite() syscalls.

This is in addition to 6fce16b1fc10.
This commit is contained in:
Valentin Bartenev 2015-11-17 19:01:41 +03:00
parent e608ba0a34
commit b9b8e6d1a5

View file

@ -176,7 +176,8 @@ ngx_thread_read_handler(void *data, ngx_log_t *log)
ssize_t
ngx_write_file(ngx_file_t *file, u_char *buf, size_t size, off_t offset)
{
ssize_t n, written;
ssize_t n, written;
ngx_err_t err;
ngx_log_debug4(NGX_LOG_DEBUG_CORE, file->log, 0,
"write: %d, %p, %uz, %O", file->fd, buf, size, offset);
@ -189,7 +190,15 @@ ngx_write_file(ngx_file_t *file, u_char *buf, size_t size, off_t offset)
n = pwrite(file->fd, buf + written, size, offset);
if (n == -1) {
ngx_log_error(NGX_LOG_CRIT, file->log, ngx_errno,
err = ngx_errno;
if (err == NGX_EINTR) {
ngx_log_debug0(NGX_LOG_DEBUG_CORE, file->log, err,
"pwrite() was interrupted");
continue;
}
ngx_log_error(NGX_LOG_CRIT, file->log, err,
"pwrite() \"%s\" failed", file->name.data);
return NGX_ERROR;
}
@ -221,7 +230,15 @@ ngx_write_file(ngx_file_t *file, u_char *buf, size_t size, off_t offset)
n = write(file->fd, buf + written, size);
if (n == -1) {
ngx_log_error(NGX_LOG_CRIT, file->log, ngx_errno,
err = ngx_errno;
if (err == NGX_EINTR) {
ngx_log_debug0(NGX_LOG_DEBUG_CORE, file->log, err,
"write() was interrupted");
continue;
}
ngx_log_error(NGX_LOG_CRIT, file->log, err,
"write() \"%s\" failed", file->name.data);
return NGX_ERROR;
}