comparison src/core/ngx_log.c @ 9296:af5b47569cb2

Core: fixed ENOSPC handling for error logs. For each connection a new ngx_log_t structure is created, and saving anything into disk_full_time field in this structure doesn't affect other connections. Fix is to move the disk_full_time field into the ngx_open_file_t structure.
author Maxim Dounin <mdounin@mdounin.ru>
date Tue, 25 Jun 2024 22:57:57 +0300
parents f18db38a9826
children e1f15d47d102
comparison
equal deleted inserted replaced
9295:c5623963c29e 9296:af5b47569cb2
167 if (log->writer) { 167 if (log->writer) {
168 log->writer(log, level, errstr, p - errstr); 168 log->writer(log, level, errstr, p - errstr);
169 goto next; 169 goto next;
170 } 170 }
171 171
172 if (ngx_time() == log->disk_full_time) { 172 if (ngx_time() == log->file->disk_full_time) {
173 173
174 /* 174 /*
175 * on FreeBSD writing to a full filesystem with enabled softupdates 175 * on FreeBSD writing to a full filesystem with enabled softupdates
176 * may block process for much longer time than writing to non-full 176 * may block process for much longer time than writing to non-full
177 * filesystem, so we skip writing to a log for one second 177 * filesystem, so we skip writing to a log for one second
181 } 181 }
182 182
183 n = ngx_write_fd(log->file->fd, errstr, p - errstr); 183 n = ngx_write_fd(log->file->fd, errstr, p - errstr);
184 184
185 if (n == -1 && ngx_errno == NGX_ENOSPC) { 185 if (n == -1 && ngx_errno == NGX_ENOSPC) {
186 log->disk_full_time = ngx_time(); 186 log->file->disk_full_time = ngx_time();
187 } 187 }
188 188
189 if (log->file->fd == ngx_stderr) { 189 if (log->file->fd == ngx_stderr) {
190 wrote_stderr = 1; 190 wrote_stderr = 1;
191 } 191 }