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
c112f3f4
Commit
c112f3f4
authored
Oct 01, 2013
by
Martin Blix Grydeland
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Keep a flag telling if the file cursor's fd should be closed on delete.
Spotted by: Coverity
parent
e773852f
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
4 deletions
+8
-4
vsl_cursor.c
lib/libvarnishapi/vsl_cursor.c
+8
-4
No files found.
lib/libvarnishapi/vsl_cursor.c
View file @
c112f3f4
...
...
@@ -288,6 +288,7 @@ struct vslc_file {
int
error
;
int
fd
;
int
close_fd
;
ssize_t
buflen
;
uint32_t
*
buf
;
};
...
...
@@ -299,7 +300,7 @@ vslc_file_delete(struct VSL_cursor *cursor)
CAST_OBJ_NOTNULL
(
c
,
cursor
->
priv_data
,
VSLC_FILE_MAGIC
);
assert
(
&
c
->
cursor
==
cursor
);
if
(
c
->
fd
>
STDIN_FILENO
)
if
(
c
->
close_fd
)
(
void
)
close
(
c
->
fd
);
if
(
c
->
buf
!=
NULL
)
free
(
c
->
buf
);
...
...
@@ -387,6 +388,7 @@ VSL_CursorFile(struct VSL_data *vsl, const char *name)
{
struct
vslc_file
*
c
;
int
fd
;
int
close_fd
=
0
;
char
buf
[]
=
VSL_FILE_ID
;
ssize_t
i
;
...
...
@@ -399,11 +401,12 @@ VSL_CursorFile(struct VSL_data *vsl, const char *name)
strerror
(
errno
));
return
(
NULL
);
}
close_fd
=
1
;
}
i
=
vslc_file_readn
(
fd
,
buf
,
sizeof
buf
);
if
(
i
<=
0
)
{
if
(
fd
>
STDIN_FILENO
)
if
(
close_fd
)
(
void
)
close
(
fd
);
vsl_diag
(
vsl
,
"VSL file read error: %s
\n
"
,
i
<
0
?
strerror
(
errno
)
:
"EOF"
);
...
...
@@ -411,7 +414,7 @@ VSL_CursorFile(struct VSL_data *vsl, const char *name)
}
assert
(
i
==
sizeof
buf
);
if
(
memcmp
(
buf
,
VSL_FILE_ID
,
sizeof
buf
))
{
if
(
fd
>
STDIN_FILENO
)
if
(
close_fd
)
(
void
)
close
(
fd
);
vsl_diag
(
vsl
,
"Not a VSL file: %s
\n
"
,
name
);
return
(
NULL
);
...
...
@@ -419,7 +422,7 @@ VSL_CursorFile(struct VSL_data *vsl, const char *name)
ALLOC_OBJ
(
c
,
VSLC_FILE_MAGIC
);
if
(
c
==
NULL
)
{
if
(
fd
>
STDIN_FILENO
)
if
(
close_fd
)
(
void
)
close
(
fd
);
vsl_diag
(
vsl
,
"Out of memory
\n
"
);
return
(
NULL
);
...
...
@@ -428,6 +431,7 @@ VSL_CursorFile(struct VSL_data *vsl, const char *name)
c
->
cursor
.
priv_data
=
c
;
c
->
fd
=
fd
;
c
->
close_fd
=
close_fd
;
c
->
buflen
=
VSL_WORDS
(
BUFSIZ
);
c
->
buf
=
malloc
(
VSL_BYTES
(
c
->
buflen
));
AN
(
c
->
buf
);
...
...
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