Klaus Demo nginx / f4d97e2
log file name for read/write errors Igor Sysoev 12 years ago
2 changed file(s) with 23 addition(s) and 13 deletion(s). Raw diff Collapse all Expand all
2121
2222 if (n == -1) {
2323 ngx_log_error(NGX_LOG_CRIT, file->log, ngx_errno,
24 "pread() failed, file \"%s\"", file->name.data);
24 "pread() \"%s\" failed", file->name.data);
2525 return NGX_ERROR;
2626 }
2727
2929
3030 if (file->sys_offset != offset) {
3131 if (lseek(file->fd, offset, SEEK_SET) == -1) {
32 ngx_log_error(NGX_LOG_CRIT, file->log, ngx_errno, "lseek() failed");
32 ngx_log_error(NGX_LOG_CRIT, file->log, ngx_errno,
33 "lseek() \"%s\" failed", file->name.data);
3334 return NGX_ERROR;
3435 }
3536
3940 n = read(file->fd, buf, size);
4041
4142 if (n == -1) {
42 ngx_log_error(NGX_LOG_CRIT, file->log, ngx_errno, "read() failed");
43 ngx_log_error(NGX_LOG_CRIT, file->log, ngx_errno,
44 "read() \"%s\" failed", file->name.data);
4345 return NGX_ERROR;
4446 }
4547
6668 n = pwrite(file->fd, buf, size, offset);
6769
6870 if (n == -1) {
69 ngx_log_error(NGX_LOG_CRIT, file->log, ngx_errno, "pwrite() failed");
71 ngx_log_error(NGX_LOG_CRIT, file->log, ngx_errno,
72 "pwrite() \"%s\" failed", file->name.data);
7073 return NGX_ERROR;
7174 }
7275
7376 if ((size_t) n != size) {
7477 ngx_log_error(NGX_LOG_CRIT, file->log, 0,
75 "pwrite() has written only %z of %uz", n, size);
78 "pwrite() \"%s\" has written only %z of %uz",
79 file->name.data, n, size);
7680 return NGX_ERROR;
7781 }
7882
8084
8185 if (file->sys_offset != offset) {
8286 if (lseek(file->fd, offset, SEEK_SET) == -1) {
83 ngx_log_error(NGX_LOG_CRIT, file->log, ngx_errno, "lseek() failed");
87 ngx_log_error(NGX_LOG_CRIT, file->log, ngx_errno,
88 "lseek() \"%s\" failed", file->name.data);
8489 return NGX_ERROR;
8590 }
8691
9095 n = write(file->fd, buf, size);
9196
9297 if (n == -1) {
93 ngx_log_error(NGX_LOG_CRIT, file->log, ngx_errno, "write() failed");
98 ngx_log_error(NGX_LOG_CRIT, file->log, ngx_errno,
99 "write() \"%s\" failed", file->name.data);
94100 return NGX_ERROR;
95101 }
96102
97103 if ((size_t) n != size) {
98104 ngx_log_error(NGX_LOG_CRIT, file->log, 0,
99 "write() has written only %z of %uz", n, size);
105 "write() \"%s\" has written only %z of %uz",
106 file->name.data, n, size);
100107 return NGX_ERROR;
101108 }
102109
190197 if (file->sys_offset != offset) {
191198 if (lseek(file->fd, offset, SEEK_SET) == -1) {
192199 ngx_log_error(NGX_LOG_CRIT, file->log, ngx_errno,
193 "lseek() failed");
200 "lseek() \"%s\" failed", file->name.data);
194201 return NGX_ERROR;
195202 }
196203
201208
202209 if (n == -1) {
203210 ngx_log_error(NGX_LOG_CRIT, file->log, ngx_errno,
204 "writev() failed");
211 "writev() \"%s\" failed", file->name.data);
205212 return NGX_ERROR;
206213 }
207214
208215 if ((size_t) n != size) {
209216 ngx_log_error(NGX_LOG_CRIT, file->log, 0,
210 "writev() has written only %z of %uz", n, size);
217 "writev() \"%s\" has written only %z of %uz",
218 file->name.data, n, size);
211219 return NGX_ERROR;
212220 }
213221
6464 return 0;
6565 }
6666
67 ngx_log_error(NGX_LOG_ERR, file->log, err, "ReadFile() failed");
67 ngx_log_error(NGX_LOG_ERR, file->log, err,
68 "ReadFile() \"%s\" failed", file->name.data);
6869 return NGX_ERROR;
6970 }
7071
8990 povlp = &ovlp;
9091
9192 if (WriteFile(file->fd, buf, size, &n, povlp) == 0) {
92 ngx_log_error(NGX_LOG_ERR, file->log, ngx_errno, "WriteFile() failed");
93 ngx_log_error(NGX_LOG_ERR, file->log, ngx_errno,
94 "WriteFile() \"%s\" failed", file->name.data);
9395 return NGX_ERROR;
9496 }
9597