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
45cf2151
Commit
45cf2151
authored
Oct 07, 2014
by
Martin Blix Grydeland
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use VFIL_allocate in vsm_zerofile
Here we insist the file is completely allocated
parent
eb1ca9d7
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
5 additions
and
13 deletions
+5
-13
mgt_shmem.c
bin/varnishd/mgt/mgt_shmem.c
+5
-13
No files found.
bin/varnishd/mgt/mgt_shmem.c
View file @
45cf2151
...
...
@@ -47,6 +47,7 @@
#include "flopen.h"
#include "vapi/vsm_int.h"
#include "vmb.h"
#include "vfil.h"
#ifndef MAP_HASSEMAPHORE
#define MAP_HASSEMAPHORE 0
/* XXX Linux */
...
...
@@ -147,8 +148,6 @@ static int
vsm_zerofile
(
const
char
*
fn
,
ssize_t
size
)
{
int
fd
;
ssize_t
i
,
u
;
char
buf
[
64
*
1024
];
int
flags
;
fd
=
flopen
(
fn
,
O_RDWR
|
O_CREAT
|
O_EXCL
|
O_NONBLOCK
,
0644
);
...
...
@@ -161,18 +160,11 @@ vsm_zerofile(const char *fn, ssize_t size)
assert
(
flags
!=
-
1
);
flags
&=
~
O_NONBLOCK
;
AZ
(
fcntl
(
fd
,
F_SETFL
,
flags
));
memset
(
buf
,
0
,
sizeof
buf
);
for
(
u
=
0
;
u
<
size
;
)
{
i
=
write
(
fd
,
buf
,
sizeof
buf
);
if
(
i
<=
0
)
{
fprintf
(
stderr
,
"Write error %s: %s
\n
"
,
if
(
VFIL_allocate
(
fd
,
(
off_t
)
size
,
1
))
{
fprintf
(
stderr
,
"File allocation error %s: %s
\n
"
,
fn
,
strerror
(
errno
));
return
(
-
1
);
}
u
+=
i
;
}
AZ
(
ftruncate
(
fd
,
(
off_t
)
size
));
return
(
fd
);
}
...
...
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