Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
varnish-cache
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Commits
Open sidebar
varnishcache
varnish-cache
Commits
79d906b7
Commit
79d906b7
authored
May 05, 2017
by
Poul-Henning Kamp
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Track FreeBSD's pidfile.c as close as possible.
parent
b264be7b
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
28 additions
and
14 deletions
+28
-14
vpf.c
lib/libvarnish/vpf.c
+10
-14
audit_vpf.sh
tools/audit_vpf.sh
+18
-0
No files found.
lib/libvarnish/vpf.c
View file @
79d906b7
...
...
@@ -76,7 +76,7 @@ vpf_read(const char *path, pid_t *pidptr)
char
buf
[
16
],
*
endptr
;
int
error
,
fd
,
i
;
fd
=
open
(
path
,
O_RDONLY
);
fd
=
open
(
path
,
O_RDONLY
|
O_CLOEXEC
);
if
(
fd
==
-
1
)
return
(
errno
);
...
...
@@ -85,6 +85,8 @@ vpf_read(const char *path, pid_t *pidptr)
(
void
)
close
(
fd
);
if
(
i
==
-
1
)
return
(
error
);
else
if
(
i
==
0
)
return
(
EAGAIN
);
buf
[
i
]
=
'\0'
;
*
pidptr
=
strtol
(
buf
,
&
endptr
,
10
);
...
...
@@ -105,17 +107,10 @@ VPF_Open(const char *path, mode_t mode, pid_t *pidptr)
if
(
pfh
==
NULL
)
return
(
NULL
);
#if 0
if (path == NULL)
len = snprintf(pfh->pf_path, sizeof(pfh->pf_path),
"/var/run/%s.pid", getprogname());
else
#endif
{
assert
(
path
!=
NULL
);
len
=
snprintf
(
pfh
->
pf_path
,
sizeof
(
pfh
->
pf_path
),
"%s"
,
path
);
}
assert
(
path
!=
NULL
);
len
=
snprintf
(
pfh
->
pf_path
,
sizeof
(
pfh
->
pf_path
),
"%s"
,
path
);
if
(
len
>=
(
int
)
sizeof
(
pfh
->
pf_path
))
{
free
(
pfh
);
errno
=
ENAMETOOLONG
;
...
...
@@ -124,12 +119,12 @@ VPF_Open(const char *path, mode_t mode, pid_t *pidptr)
/*
* Open the PID file and obtain exclusive lock.
* We truncate PID file here only to remove old PID immediatel
l
y,
* We truncate PID file here only to remove old PID immediately,
* PID file will be truncated again in VPF_Write(), so
* VPF_Write() can be called multiple times.
*/
fd
=
VFL_Open
(
pfh
->
pf_path
,
O_WRONLY
|
O_CREAT
|
O_TRUNC
|
O_NONBLOCK
,
mode
);
O_WRONLY
|
O_CREAT
|
O_TRUNC
|
O_
CLOEXEC
|
O_
NONBLOCK
,
mode
);
if
(
fd
==
-
1
)
{
if
(
errno
==
EWOULDBLOCK
&&
pidptr
!=
NULL
)
{
errno
=
vpf_read
(
pfh
->
pf_path
,
pidptr
);
...
...
@@ -139,6 +134,7 @@ VPF_Open(const char *path, mode_t mode, pid_t *pidptr)
free
(
pfh
);
return
(
NULL
);
}
/*
* Remember file information, so in VPF_Write() we are sure we write
* to the proper descriptor.
...
...
tools/audit_vpf.sh
0 → 100644
View file @
79d906b7
#!/bin/sh
#
# Script to compare vpf.c with FreeBSD's pidfile.c
#
# Run this on a up-to-date FreeBSD source tree
sed
'
s/vpf_/pidfile_/g
s/VPF_/pidfile_/g
s/pidfile_fh/pidfh/g
s/pidfile_Write/pidfile_write/g
s/pidfile_Close/pidfile_close/g
s/pidfile_Remove/pidfile_remove/g
s/pidfile_Open/pidfile_open/g
s/ (void)/ /g
'
lib/libvarnish/vpf.c |
diff
-ub
/usr/src/lib/libutil/pidfile.c -
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment