comparison src/os/unix/ngx_files.c @ 4737:9acc1a5a5b9a

Made sure to initialize the entire "struct flock" allocated on stack.
author Ruslan Ermilov <ru@nginx.com>
date Tue, 03 Jul 2012 13:05:18 +0000
parents d620f497c50f
children 4163fb9dcfcb
comparison
equal deleted inserted replaced
4736:cebbe4fda8aa 4737:9acc1a5a5b9a
411 ngx_err_t 411 ngx_err_t
412 ngx_trylock_fd(ngx_fd_t fd) 412 ngx_trylock_fd(ngx_fd_t fd)
413 { 413 {
414 struct flock fl; 414 struct flock fl;
415 415
416 fl.l_start = 0; 416 ngx_memzero(&fl, sizeof(struct flock));
417 fl.l_len = 0;
418 fl.l_pid = 0;
419 fl.l_type = F_WRLCK; 417 fl.l_type = F_WRLCK;
420 fl.l_whence = SEEK_SET; 418 fl.l_whence = SEEK_SET;
421 419
422 if (fcntl(fd, F_SETLK, &fl) == -1) { 420 if (fcntl(fd, F_SETLK, &fl) == -1) {
423 return ngx_errno; 421 return ngx_errno;
430 ngx_err_t 428 ngx_err_t
431 ngx_lock_fd(ngx_fd_t fd) 429 ngx_lock_fd(ngx_fd_t fd)
432 { 430 {
433 struct flock fl; 431 struct flock fl;
434 432
435 fl.l_start = 0; 433 ngx_memzero(&fl, sizeof(struct flock));
436 fl.l_len = 0;
437 fl.l_pid = 0;
438 fl.l_type = F_WRLCK; 434 fl.l_type = F_WRLCK;
439 fl.l_whence = SEEK_SET; 435 fl.l_whence = SEEK_SET;
440 436
441 if (fcntl(fd, F_SETLKW, &fl) == -1) { 437 if (fcntl(fd, F_SETLKW, &fl) == -1) {
442 return ngx_errno; 438 return ngx_errno;
449 ngx_err_t 445 ngx_err_t
450 ngx_unlock_fd(ngx_fd_t fd) 446 ngx_unlock_fd(ngx_fd_t fd)
451 { 447 {
452 struct flock fl; 448 struct flock fl;
453 449
454 fl.l_start = 0; 450 ngx_memzero(&fl, sizeof(struct flock));
455 fl.l_len = 0;
456 fl.l_pid = 0;
457 fl.l_type = F_UNLCK; 451 fl.l_type = F_UNLCK;
458 fl.l_whence = SEEK_SET; 452 fl.l_whence = SEEK_SET;
459 453
460 if (fcntl(fd, F_SETLK, &fl) == -1) { 454 if (fcntl(fd, F_SETLK, &fl) == -1) {
461 return ngx_errno; 455 return ngx_errno;