comparison src/os/unix/ngx_files.c @ 160:73e8476f9142 NGINX_0_3_27

nginx 0.3.27 *) Change: the "variables_hash_max_size" and "variables_hash_bucket_size" directives. *) Feature: the $body_bytes_sent variable can be used not only in the "log_format" directive. *) Feature: the $ssl_protocol and $ssl_cipher variables. *) Feature: the cache line size detection for widespread CPUs at start time. *) Feature: now the "accept_mutex" directive is supported using fcntl(2) on platforms different from i386, amd64, sparc64, and ppc. *) Feature: the "lock_file" directive and the --with-lock-path=PATH autoconfiguration directive. *) Bugfix: if the HTTPS protocol was used in the "proxy_pass" directive then the requests with the body was not transferred.
author Igor Sysoev <http://sysoev.ru>
date Wed, 08 Feb 2006 00:00:00 +0300
parents df17fbafec8f
children 13710a1813ad
comparison
equal deleted inserted replaced
159:25c27e983933 160:73e8476f9142
233 233
234 return NGX_OK; 234 return NGX_OK;
235 } 235 }
236 236
237 237
238 ngx_int_t 238 ngx_err_t
239 ngx_lock_file(ngx_file_t *file) 239 ngx_trylock_fd(ngx_fd_t fd)
240 { 240 {
241 ngx_err_t err;
242 struct flock fl; 241 struct flock fl;
243 242
244 fl.l_whence = SEEK_SET; 243 fl.l_start = 0;
245 fl.l_len = 0; 244 fl.l_len = 0;
246 fl.l_pid = 0; 245 fl.l_pid = 0;
247 fl.l_type = F_WRLCK; 246 fl.l_type = F_WRLCK;
247 fl.l_whence = SEEK_SET;
248
249 if (fcntl(fd, F_SETLK, &fl) == -1) {
250 return ngx_errno;
251 }
252
253 return 0;
254 }
255
256
257 ngx_err_t
258 ngx_lock_fd(ngx_fd_t fd)
259 {
260 struct flock fl;
261
248 fl.l_start = 0; 262 fl.l_start = 0;
249 263 fl.l_len = 0;
250 if (fcntl(file->fd, F_SETLK, &fl) == -1) { 264 fl.l_pid = 0;
251 err = ngx_errno; 265 fl.l_type = F_WRLCK;
252 266 fl.l_whence = SEEK_SET;
253 if (err == NGX_EAGAIN) { 267
254 return NGX_BUSY; 268 if (fcntl(fd, F_SETLKW, &fl) == -1) {
255 } 269 return ngx_errno;
256 270 }
257 ngx_log_error(NGX_LOG_ALERT, file->log, err, 271
258 "fcntl(%s, F_SETLK, F_WRLCK) failed", file->name.data); 272 return 0;
259 273 }
260 return NGX_ERROR; 274
261 } 275
262 276 ngx_err_t
263 return NGX_OK; 277 ngx_unlock_fd(ngx_fd_t fd)
264 } 278 {
265
266
267 ngx_int_t
268 ngx_unlock_file(ngx_file_t *file)
269 {
270 ngx_err_t err;
271 struct flock fl; 279 struct flock fl;
272 280
273 fl.l_whence = SEEK_SET; 281 fl.l_start = 0;
274 fl.l_len = 0; 282 fl.l_len = 0;
275 fl.l_pid = 0; 283 fl.l_pid = 0;
276 fl.l_type = F_UNLCK; 284 fl.l_type = F_UNLCK;
277 fl.l_start = 0; 285 fl.l_whence = SEEK_SET;
278 286
279 if (fcntl(file->fd, F_SETLK, &fl) == -1) { 287 if (fcntl(fd, F_SETLK, &fl) == -1) {
280 err = ngx_errno; 288 return ngx_errno;
281 289 }
282 if (err == NGX_EAGAIN) { 290
283 return NGX_BUSY; 291 return 0;
284 } 292 }
285
286 ngx_log_error(NGX_LOG_ALERT, file->log, err,
287 "fcntl(%s, F_SETLK, F_UNLCK) failed", file->name.data);
288
289 return NGX_ERROR;
290 }
291
292 return NGX_OK;
293 }