Commit 6f949e26 authored by Dag Erling Smørgrav's avatar Dag Erling Smørgrav

Sync with FreeBSD


git-svn-id: http://www.varnish-cache.org/svn/trunk/varnish-cache@3335 d4fa192b-c00b-0410-8231-f00ffab90ce4
parent 81cfa49d
...@@ -26,17 +26,17 @@ ...@@ -26,17 +26,17 @@
* *
* $Id$ * $Id$
* Derived from: * Derived from:
* $FreeBSD: src/lib/libutil/flopen.c,v 1.7 2007/05/23 12:09:33 des Exp $ * $FreeBSD: head/lib/libutil/flopen.c 184094 2008-10-20 18:11:30Z des $
*/ */
#include "config.h" #include "config.h"
#include <sys/file.h>
#include <sys/stat.h> #include <sys/stat.h>
#include <errno.h> #include <errno.h>
#include <fcntl.h> #include <fcntl.h>
#include <stdarg.h> #include <stdarg.h>
#include <string.h>
#include <unistd.h> #include <unistd.h>
#include "config.h" #include "config.h"
...@@ -46,8 +46,8 @@ int ...@@ -46,8 +46,8 @@ int
flopen(const char *path, int flags, ...) flopen(const char *path, int flags, ...)
{ {
int fd, operation, serrno, trunc; int fd, operation, serrno, trunc;
struct stat sb, fsb;
struct flock lock; struct flock lock;
struct stat sb, fsb;
mode_t mode; mode_t mode;
#ifdef O_EXLOCK #ifdef O_EXLOCK
...@@ -63,10 +63,9 @@ flopen(const char *path, int flags, ...) ...@@ -63,10 +63,9 @@ flopen(const char *path, int flags, ...)
va_end(ap); va_end(ap);
} }
memset(&lock, 0, sizeof lock);
lock.l_type = ((flags & O_ACCMODE) == O_RDONLY) ? F_RDLCK : F_WRLCK; lock.l_type = ((flags & O_ACCMODE) == O_RDONLY) ? F_RDLCK : F_WRLCK;
lock.l_start = 0;
lock.l_whence = SEEK_SET; lock.l_whence = SEEK_SET;
lock.l_len = 0;
operation = (flags & O_NONBLOCK) ? F_SETLK : F_SETLKW; operation = (flags & O_NONBLOCK) ? F_SETLK : F_SETLKW;
trunc = (flags & O_TRUNC); trunc = (flags & O_TRUNC);
......
...@@ -25,7 +25,7 @@ ...@@ -25,7 +25,7 @@
* *
* $Id$ * $Id$
* Derived from: * Derived from:
* $FreeBSD: src/lib/libutil/pidfile.c,v 1.5 2007/05/11 11:10:05 des Exp $ * $FreeBSD: head/lib/libutil/pidfile.c 184091 2008-10-20 17:41:08Z des $
*/ */
#include "config.h" #include "config.h"
...@@ -230,14 +230,8 @@ vpf_close(struct pidfh *pfh) ...@@ -230,14 +230,8 @@ vpf_close(struct pidfh *pfh)
static int static int
_vpf_remove(struct pidfh *pfh, int freeit) _vpf_remove(struct pidfh *pfh, int freeit)
{ {
struct flock lock;
int error; int error;
lock.l_type = F_UNLCK;
lock.l_start = 0;
lock.l_whence = SEEK_SET;
lock.l_len = 0;
error = vpf_verify(pfh); error = vpf_verify(pfh);
if (error != 0) { if (error != 0) {
errno = error; errno = error;
...@@ -246,10 +240,6 @@ _vpf_remove(struct pidfh *pfh, int freeit) ...@@ -246,10 +240,6 @@ _vpf_remove(struct pidfh *pfh, int freeit)
if (unlink(pfh->pf_path) == -1) if (unlink(pfh->pf_path) == -1)
error = errno; error = errno;
if (fcntl(pfh->pf_fd, F_SETLK, &lock) == -1) {
if (error == 0)
error = errno;
}
if (close(pfh->pf_fd) == -1) { if (close(pfh->pf_fd) == -1) {
if (error == 0) if (error == 0)
error = errno; error = errno;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment